That may work for the majority of birds, and I agree that a good jolt should work.I don't know if it needs to 'hurt', but it does need to give them a good jolt.
In this case, HeatherKellyP said that,
'Whenever I peck back at my hen, it makes her even more aggressive and I think she'll go on forever,' and, 'Maybe repetitively pecking back as long as she'll go will work, but she's a stubborn thing and makes me think she'll go on for quite a while.'
For such a bird, if a good jolt doesn't work, a little sting may be needed - which is what I meant by 'it needs to hurt'.