Whatever the reason or the background, an immediate reaction is necessary. Perhaps the parents and you, and anyone else who is close to the child should agree on a strategy and all react in the same way when he does this.
Only the parents/grandparents etc know what would help in this situation. A stern look, a certain phrase, diverting his attention, holding him firmly - whatever suits.
He could be copying something he has seen, there may be someone treating him like this that he can't tell you about, he may have something that is building up inside him (jealousy of a younger sibling, worries at school), or he may have some condition (something like Tourettes - I'm afraid I have no idea about this kind of thing). As with most things, it needs getting to the bottom of.
Do keep us posted as to what happens, and if it stops.