Keep your headphones plugged in.
BAM!
Solved!
BAM!
Solved!
Of course, if one were playing music or something, it would be obvious that the switch had been circumvented.
Also consider that if you played the sound at maximum volume it might actually be audible some distance away from the headphones.
On Linux you can choose different behavior; so it's apparently software. At least, on machines I've worked on. Depending on that dropdown, I can plug in headphones and the built-in speakers will continue to output.