This is called the Hangman by neatproducts. It locks into the iPod/iPhone socket and its other end snaps onto a lanyard/belt loop/flak jacket. And it does a pretty good job of holding my earphones: Wrap the cord around the Hangman and slide the ends into the notch (like thread on a cotton reel). Leave it attached or remove it and stow the headphones neatly away.
I'm going to us it to store my headphones and I'll attach it to a lanyard for those times I have my iPhone in my shirt pocket and listen to music through the built-in speaker.