You can indeed switch between sound output devices, but on iMac "headphones" and "internal speakers" are the same device, so switching is only available if you have something else, like USB speakers or an AirPlay device.
If you click the sound button on the menu bar to open the menu, it will have a headphones entry if headphones are plugged in, and an internal speakers entry if headphones are not plugged in.
As you plug in and unplug headphones, with the menu showing, that entry dynamically changes. (Same on the Sound panel in System Preferences).
This appears to be entirely a software decision on Apple's part, rather than some sort of electrical/mechanical design that forces the speakers to be disconnected when the headphones are inserted. In this discussion [1] on Ask Different people report that when they run Windows via Bootcamp, they can choose via software between headphones and internal speakers.
BTW, my iMac is a 2017 model. They might have changed this with later models.
If you click the sound button on the menu bar to open the menu, it will have a headphones entry if headphones are plugged in, and an internal speakers entry if headphones are not plugged in.
As you plug in and unplug headphones, with the menu showing, that entry dynamically changes. (Same on the Sound panel in System Preferences).
This appears to be entirely a software decision on Apple's part, rather than some sort of electrical/mechanical design that forces the speakers to be disconnected when the headphones are inserted. In this discussion [1] on Ask Different people report that when they run Windows via Bootcamp, they can choose via software between headphones and internal speakers.
BTW, my iMac is a 2017 model. They might have changed this with later models.
[1] https://apple.stackexchange.com/questions/6510/use-internal-...