This is surprisingly normal, It's a way to express more frustration than the child is able to endure at that moment. Especially for children who are still short on verbal skills, this is a way to express themselves in a most visceral way. And he's not allowed to hit others, so he hits… himself. He may also be expressing his sense that you are angry with him, depending on the tone of your "no!"
Three things will gradually move him past this stage:
1. Help him use words for his feelings. If he can't yet shape his mouth to make those words, give him signs he can use, or model alternatives like punching a pillow. The ability to communicate is terribly important to a 3yo, and much of his dismay is probably rooted in his inability to express himself verbally. And be sure to listen, early and often, for whatever he is trying to express.
2. Don't react emotionally. Give a gentle direction in a soft voice, something like "Sweetheart, we don't hit people, not even yourself. Touch your face gently." And perhaps guide him in this. Too strong a reaction from parents may set the stage for later manipulations. Kids don't necessarily move into manipulation in a planned way, but their little brains are constantly cataloging cause and effect, and they will quite naturally do what works, what is most likely to get them an outcome they want.
3. Find ways to give "yes" messages instead of "no" messages. Instead of "No, you can't have candy before dinner," try "Ooh, candy sounds so yummy. Let's put a piece right here for you to have right after dinner!" Instead of "Stop doing that and come over here right now," try "Can you hop on one foot? Can you hop all the way over to me?" Instead of "No more delays – get your shoes on now!" try "As soon as your shoes are on, we can go out and do ________." And so forth.