N.,
I would add one more suggestion to the others already voiced below. When my son started hitting himself and slamming his head into the wall to make himself cry I pulled him into my lap and wrapped my arms around him in a big hug. He was about 3 at the time and was frustrated with a timeout I gave him.
At this time he really didn't like being restrained, but in a calm voice I told him I wouldn't let him go until he was ready to be calm and stopped hurting himself. I hummed and sang in a very quiet voice while he was screaming at the top of his lungs. After about 15 minutes he calmed down and I told him, as a mommy I couldn't let him hurt himself on purpose in that way and the only way I could stop him was to hug him in my lap. I explained if he repeated his actions I would restrain him again. We talked about better ways to express his anger: hitting a pillow, his bed, the couch, etc. and inappropriate ways: hitting a person, biting, throwing things, etc. We haven't had a problem with this particular behavior since, and he never hit or bit anyone. He is now a typical 6, almost 7, year-old.
Good luck!
-C..