My Mother said I did the same thing when I was little. It sounds like you have an intelligent child who gets bored easily. This may be a precurser to a chemical imbalance in the brain. Monitor the child carefully, and see if there are any other signs of discomfort. Many psychiatric disorders, very treatable ones, manifest in the early to late teens. Does he respond to stimuli as other children do? Does he have a low frustration tolerance, is he combative and uncooperatove, these are things to keep a 'heads up' for. Keep in close communication with school cousellors for information, so you are prepared if he diagnoses with Adhd or later on with a chemical imbalance. I have a mental illness, my mom suspected it, my Dad was in denial, still is. When I go for meds or therapy I notice the rocking and sometimes head banging in other clients waiting to be seen.
As above ,headbanging and rocking can be indicative of certain syndromes. In working with mentally handicapped children and adults who are prone to this behaviour,I have found that it is mainly as a result of boredom and frustration. Even bored animals in the zoo are prone to similar behaviours. As a therapy I found that play worked well. Distract the child with challenging activities that are physical in nature.kicking a ball about or flying a kite or anything that is different from the norm. After a short while you will find the child will be less likely to do this and may even sleep better. I have always found play as a great therapy for kids. :)
Head banging and rocking are considered as common childhood self-comforting habits. However, in your case it is strange to know that they are doing them at such inappropriate age as these habits go by the age of 2. They are normally harmless. But they can also be a sign of autism, tourette syndrome and seizure disorders or even some other developmental disorder. I am sure you have been to plenty of Pediatricians however, this time try a psychologist. As he would be able to find the source of stress for children and tell you ways to eradicate this behavior.