Distract him. He's doing it because it's a comfort thing (like thumb-sucking or finger-sucking is for many kids) and he's doing it at times he's not occupied. As soon as he starts, distract him with something to do with his hands -- give him a ball, give him a sticker sheet and page to put the stickers on (great suggestion from another person who posted), ask him to play patty-cake with you, go pick up some leaves on a walk and talk about them, whatever. You may not be able to "break" him of it completely; it's almost impossible to force another human to sleep when we want, use the toilet when we want, or stop doing things that deep-down are reflexive comfort for them like thumb-sucking or nail-biting. But you can distract him to try to reduce it. Please don't treat it like "bad behavior" and punish him for it, especially as young as he is; he's not doing it to be naughty or to get at you.