Depends on their mood and entirely disagree with FunkyDunc suggesting they just understand it gets attention if they still do it.
But if you really want to put a stop to it there needs to be a punishment as will as no.
Get on to his level, look into his eyes and tell him it is wrong and that if he does it again he will go in the naughty corner/step or whatever. The ‘rule’ is one minute per year so just a minute. Tell him he is being put there because he has been naughty because he hurt the dog.
EVERY TIME he does it, warn him and give him the same punishment.
We had to do it at a similar age when one of our girls started biting the other and it has (mostly) worked.