Use internal speakers with others plugged into headphones jack
There is a way to do this but it is difficult and probably not for every user. What happened is Apple does have a "hardware" switch built in, which sends a signal to disable/enable the internal speaker. Because Windows or other OS simply doesn't have such function built in, it will just be a weird signal that does nothing.
Option 1
I cannot disable this signal, it probably requires some highly skilled kext modifier, but I found a way to reset the internal speaker after it gets disabled. It will not stick after a reboot, so you have to do it every time after the booting.
Backup your AppleHDA.kext in /System/Library/Extensions/
Show package content of this file, go to Contents/Plugins then remove
AppleHDAHALPlugIn.bundle
.-
Reload the kext by running
sudo kextunload /System/Library/Extensions/AppleHDA.kext sudo kextload /System/Library/Extensions/AppleHDA.kext ps aux | grep 'coreaudio[d]' | awk '{print $2}' | xargs sudo kill
Recover the backup file AppleHDA.kext (or your computer won't boot next time you reboot).
Note, if you unplug the headphone, it will still show in your audio device panel. Tested working on a retina iMac. Not working on a retina Macbook (no audio afterward).
Option 2
I have a better way to do this (this method no longer works for 10.12.x+).
Download the following files:
https://mega.co.nz/#!js4gmZbI!xNFCxGT5zPYCS8RLtxk4xZQxNk0oP2sH8RjXbBqgmE0
https://mega.co.nz/#!ulw13BzD!Y1k564bTSxZrePpPL-si5h65XULwnYeEMwH-l0lSLfIOpen up the first download, and drag the second download into it. It will take 10 minutes to install. Then restart your system.
You will not have line out and internal speakers both in your sound panel at all time, even when your headphone is not plugged in.
Tested on macOS 10.11, iMac Retina and not working on MacBook Pro Retina.
Pretty sure it can't be done with the built-in headphone jack. What you could try is getting a USB soundcard (one example, but there are lots out there for $20 or so) to plug your headphones into. That should give you two options in the sound preferences.
PS, if you option-click the speaker icon in the menu bar, you get a quicker way to swap inputs/outputs than going to the sound preference pane every time.
Just found a solution that works or me - I use an HDTV as an additional monitor, and with headphones plugged in there I can route the audio to the external monitor. I can now switch between iMac speakers and headphones without unplugging the headphones.