Breakaway is an interesting app that lets you control iTunes differently. It uses as input the headphone jack's sensors and the mute button. For example, by default, Breakaway pauses the music when you remove your headphones from your Mac. It can also pause the music when you hit the mute button. That happens to me a lot: I hit "mute" to do something and when I get back, my song is done. Breakaway also has support for custom scripts that can carry out actions when you remove your headphones.
Breakaway runs on the menu bar, and you can access the preferences window from there. I took a look at the custom applescript support. This feature allows you to execute a script when you mute the sound, when you unmute it, when you connect your headphones or when you disconnect them. There are a few sample applescripts available, and you can make your own too. Among the included scripts there were some that change your status in iChat and Skype to available and not available, and one to pause playback in VLC.
In my testing, the app did a good job of pausing the music when I removed the headphones, but it didn't work when I muted the sound.