If you have a dog, you probably know all of his little idiosyncrasies well. More than likely, one of them is kicking his leg when you scratch a certain place on his stomach. Long-time dog owners will know that almost all dogs do this. Typically it happens when you scratch them in a place known as the "saddle" region, which includes the belly, flanks and back. Some kick one leg, some kick the other, and the height and speed of the kick can vary depending on where you scratch and on the individual dog. It doesn't make much sense -- he kicks his leg even though there's no way that leg can actually reach your hand to make it stop. It's funny, but have you ever stopped to ponder why it's happening?
Dogs shake or kick their legs when you scratch them because of something known as the scratch reflex. It's a completely involuntary reaction, which explains why your dog may look as puzzled as you do when it starts to happen. When you scratch or tickle your dog's belly, it irritates him, much the same way that the wind or a bug might. It activates nerves under his skin that are connected to his spinal cord and relays a message to his leg muscles to kick in an attempt to get rid of the irritant. Of course, you're the one both providing the "itch" and "scratching" it, so it's a completely pointless act.
The scratch reflex does have one purpose -- it's reliable enough that veterinarians sometimes use it to assist in diagnosing nerve damage or neurological problems. And while we've called it an irritant, you're not really irritating your dog at all. Most dogs like a scratch on their bellies, so just move to another spot. If he really doesn't like it, he'll just let you know by moving away. Think of it as similar to our knee-jerk reflex, when the doctor taps your knee and your leg kicks out. Or when you scratch a cat at the base of his tail and his rear end rises up. It's just one of those quirks of animal anatomy.