My son did this, and still does. He is now 4 1/2. My inlaws freaked when they saw it.. like he was having some sort of "fit" but he is fine. Some kids just do this. I first noticed he was banging his head when he was in the car seat and mumbling alot and he would do this every time he started to fall asleep. Then, in his bed he would curl up in a ball on his stomach and would cover his face with his hands and roll back and forth rather violently humming... till he fell asleep. I tried to stop it but it is as if he has this "internal radio" that helps him sleep and he feels the need to have it "cranked up". When he was an infant I would have to leave the radio on at night to help him sleep... then it stopped working and I had to place it under the crib and turn the bass up a bit. It is like when you get a puppy and they tell you to put a ticking clock in the kennel so they won't cry all night (because it mimics a heartbeat)... to some kids it is the same thing... it is a soothing thing.
I wouldn't freak out too much my son has begun out growing it (I am glad the head banging has stopped). It doesn't happen as often and I am betting we all do similar things on different scales... my husband has to tap his feet for several minutes before he falls asleep... drives me nuts :) I am sure there are things we all do that we rarely notice now... but because they are our kids.... they may draw more attention.
Keep and eye on it... if it really bothers you.. you can take him to a specialist, but chances are that may just really traumatize him and he may out grow it.
good luck :)
-T. (mom of 1)