Ah, the terrible twos! (Meaning age one two and three and maybe even into age 4 lol.) The very best of luck to you during these years: it looks like your child really has a strong will!
Head banging does occur in a lot of children. Some of us even do it as adults! This is actually a soothing process...somewhere a long the line he realized that if he bangs his head it can relieve his stress in the situation. The good thing is that if he does hurt himself, he's going to stop and maybe it will take a few times, but he will learn that he can hurt himself this way and will find another way to get relief. He should eventually grow out of this to matter what.
You should keep his pediatrician aware that this behavior is going on, but usually doctors will just let them do it unless there are significant bumps and bruises: Since he does end up in pain when he does it too hard, this is the best teacher and prevention...his own nervous system. Not only that, kids this age aren't strong enough to cause themselves brain damage.
The only concern that you might consider (which I don't think is a problem here) is that he could have another condition which might include a developmental disability. IF he was unaware of his surroundings or unresponsive to you, then that would be a real concern. But this really does look like a regular temper tantrum to me.
I hope he grows out of this soon. When he is a little older, you might even be able to introduce him to something a little less damaging to your nerves.
http://www.mamashealth.com/child/headbang.
asp