Is there a way to disable the internal speaker in Macbook?
Solution 1:
When you switch audio outputs, the volume level reverts to whatever level it was at when you last used that output. That means that if you mute the internal speaker before plugging in headphones, it'll stay muted if you accidentally disconnect your headphones.
If that's not enough, you can also use Soundflower. It's an extension designed to let your Mac record its own audio output, which it does by creating virtual input and output options that feed directly into each other. That means that you can hold down Option, click on the volume icon in the menu bar, and select one of the Soundflower options as your audio output before plugging in your headphones and selecting them as the output device. If your headphones get disconnected, your audio output will default to Soundflower, which doesn't send anything through the speaker.