Baby not eating

I feed my 5 month old every 2 hours and for about a month now every other time he eats he gets to distracted. He will latch and let go every couple of seconds. One it hurts to keep re latching so much. Sometimes he cries when he lets go. I’ve tried putting a blanket over so he has nothing to look at and it did nothing. I have also tried holding his head lightly in place but gets pissed off if I don’t let him let go. It hurts very bad and I’m not sure how to fix this