The condition known as 'blue balls' is a state of frustrated arousal, and while not all men experience it (lucky b***ards), I can testify first hand that it does exist, and for those of us unlucky enough to suffer from it, is quite painful...that said, however, it is NOT necessary for a man to have sex to alleviate it, and NO woman should feel obligated to perform any sexual act on the claim of such suffering.
Again however, it is EXTREMELY rude to get a man that aroused, and not offer to help in some way... Even if it's just a little lube and a bit of hand work... Really. The actual relief is from the orgasm and ejaculation, and the chemicals released upon reaching climax, allowing the tissues in the area to go lax and return to normal.
Of course that comment about how rude it is does not just apply to women being rude, as it is not a condition that men suffer from alone. Some women have clearly reported that if driven to a state of extreme arousal that is left unfulfilled, the sensation is not unlike menstrual cramps.
The reason for all this discomfort is the sheer amount of blood and blood pressure that is induced in the area, and it takes time for those tissues to relax enough on their own to release the pressure enough to return to normal, so the residual pressure and inflammation causes pain.
Now, all that said, you asked if it 'hurts his penis'... The simple answer is a resounding NO. The pain experienced is temporary, usually lasting between 1 and 3 hrs afterward if there is no ejaculatory relief, then all is as normal. But frankly, I know I've never been pleased with the women inclined to leave a man in that position, and I doubt anyone else does as well, so if you aren't already in a relationship with him, you may damage your chances of starting one with him. The easiest way to really help with this kind of thing is to not get to that level of arousal in the first place. If you realize that you aren't going to want to complete ANY sexual act, just have a heart, and don't let things go that far. I, and any others like me will appreciate the consideration, even if we don't appreciate having lost the chance to get hold of your hot bod.
I hope this helps...