Is it okay to bite my child to teach him that biting hurts?

Yes. I agree with dr webb in general but find some kids need a "hot" moment.Kids don't understand hot untill they have touched something hot & put the word & sensation together.Kids who bite don't necessarily understand pain is inflicted.An immediate one time bite from a parent often opens them to the concept of pain & bad choice. Do it within 30 sec or the kid won't understand & never break the skin.
No. Instead, try stopping by the unwanted behavior (biting) by immediately taking your child out of the situation and giving a time out. Explain in simple, clear terms that biting is not ok. Teach about apologizing as well.