Knee bouncing is a habit that is common in many people. The cause of knee bouncing can be physiological and/or psychological.
Physiological reasons for knee bouncing can be related to restless leg syndrome in which patients complain of electric sensation and/or bug crawling sensation. This typically occurs most significantly at night when patients have uncontrolable leg twitching or movement. The treatment for this is a dopamine agonist such as requip or mirapex. Other physiologic reasons include prolonged sitting or standing.
Psychological/psychiatric cause can include anxiety or a nervous tic. In such cases taking a medication such as klonopin, xanax or valium can also help. Some psychiatrists have also used gabapentin (neurontin) on an off-label basis to treat anxiety.
As there are medications which are available to treat this condition in either case, it would be neccary to see your primary care doctor to get a referral to a neurologist or a psychiatrist.