I know it's hard because it hurts like the Dickens but ... don't give a big reaction.
It becomes entertaining for them. They don't actually realize they are causing you pain but they learn to enjoy the cause and effect of "If I do this, mummy reacts that way."
Remove your baby from your breast and say, "No, that hurts me." End the feed. They are just playing and not focusing. If your baby protests, say, "Your were biting me. That's not ok. We can try again in 15 minutes." And then move on.
Even if your baby is quite young, communicating with your words, tone of voice, facial expression and body language gets the message across that when feeding he's not to attempt to bite you again. Biting ends the feed.
As your baby maneuvers through this tricky stage, be very vigilant during the feeding times. As you sense the feed coming to an end put down any distractions and pay attention to his cues. If you sense your baby start to clench his jaw or begin grazing (about to bite again), slide your pinky into the corner of his mouth planting the tip of your pinky in between his top and bottom gums. This will break the suction and also protect your nipple, giving it plenty of room to slide out without getting bit.
Remember, your baby isn't intentionally trying to harm you. He can't feel the pain you do and he doesn't understand it. Don't take it personally. Be calm and matter of fact. If you sense the feed wasn't actually finished, try to feed again in 15 minutes after you have both had a break.
He's learning cause and effect. Help him learn that the result of biting stops the feed altogether. Which is much less entertaining than hearing your squeal.