Yep, you are doing the right thing. It might be cute when he's a kitten, but he'll grow up and those tiny needles will become not-so-tiny.
When he tries to re-engage you like that, just walk away, or else stand quite still so that your feet make a very uninteresting target. I suggest thick socks if you try the latter, though! Cats are totally attracted to motion. They're hunters by nature and if you move, they notice you. That's why scared mice and rats freeze in place--because predators don't notice them as much if they stay still. A kitten practicing stalking behavior might think of your feet as much more interesting if you moved; so, either don't move, or move completely out of range, so either way Kitty realizes she doesn't get to play with the feet.
Also, you might try yelping or making a high-pitched "Yeooow!" sound to tell him it hurts. Another cat would yell like that, and probably whack him with a paw, too; but since it'd just be mean to whack him with your hand (which is way bigger than a cat's paw, after all), stick to yelling. :P