Speak to your pediatrician. It's probably nothing to worry about, but I know that children with Autism Spectrum Disorders do hit themselves, bang their heads or rock themselves when upset.
My daughter was a head-banger. She was diagnosed with a high-functioning Autism Spectrum Disorder when she was in elementary-school. In retrospect there were other signs too.. but you'd never have put it together till you had the diagnosis.
She's now 14, carrying a full honor's load in her freshman year with a 96% average, participating in Marching Band, Chorus, Drama, Environmental Club, Key club, the National Honor Society and has a wonderful but small circle of friends ( with a boyfriend she thinks we don't know about ;-).
An Autism Spectrum Disorder diagnosis is not a "death knell" for your child. Just knowing what's going on helps to find specialized ways to help them succeed. But as I said, it may be something that is normal for you child.. Just be aware, and talk to the doc.
Val