Apple - Auto mute macbook on headphone removal
Unplug/disconnect your headphones, and mute the system volume. For added security, turn the volume all the way down. Plug in your headphones, and your volume should remain the same. The system will automatically switch between mute/no volume and the volume you have set for your headphones.
This is something that works on at least OSX 10.8 (I can't speak for sure on older versions of OSX), and a late 2008 or later Macbook. I tested it on both bluetooth and corded headphones.
So I wrote a Mac app to do just that - automatically mute the volume when headphones get disconnected. It's called AutoMute and is available for $2.99 on the App Store, or you could just build from the source available on github for free.
I like to use the ControlPlane app for this. An added bonus is you can do more than just mute/unmute, such as turning dock auto-hiding off or on depending on whether you have external monitors attached or not.
Here is the setup I use:
On the Contexts tab of ControlPlane's preferences, add a context named Headphones and another named Speakers.
On the Evidence Sources tab, ensure that the Audio Output evidence source is enabled
On the Rules tab, click the Add (+) button, select Add Audio Output Rule..., and set the following options:
a. Audio output going to: Internal speakers
b. Context: Speakers
c. Confidence: 100% (Drag slider all the way to the right)
Repeat step (3) with the following settings:
a. Audio output going to: Headphones
b. Context: Headphones
c. Confidence: 100%
On the Actions tab, click the Add (+) button, select Sound and Music Actions > Mute and set the following options:
a. Toggle muting of system audio: Mute system audio
b. at context: Speakers
c. On arrival
Repeat step (5) with the following settings:
a. Toggle muting of system audio: Unmute system audio
b. at context: Headphones
c. On arrival
If you would prefer to have a single context, you can get by with that as well by (for example) having a Headphones context with mute on departure from the context.