You could try showing him what he can do instead. So we say to dd 'no, be gentle' and then take her hand and stroke my hair gently with it. She is the same age as yours and I find this has worked really well. She will now go and stroke other children's hair at nursery
My son has just turned 15 months, and has began to hair pull. He certainly gave the odd tug at another child's hair at toddler group when he was younger, though not often, but now he pulls my and his father's hair when we have him in our arms. Sometimes it's because he's cross, sometimes it's just idly, but he's strong and it really hurts! My question is how best to deal with it, as he's so young? At the moment, we are putting him down, tapping the back of his hand to get his attention, getting him to look at us, looking very serious and saying 'No, no, no hair pulling' several times. Is there a better way? I know it's just a phase, but he also scratched me down the side of my face out o f the blue the other day, and it has left a big mark!