For example, my desktop motherboard has two separate sound cards; one for the rear I/O and one for the front headphone and microphone jacks. I can give either sound card priority over the other, such that if one is connected it uses it by default, or vice versa. I can also direct the output of individual applications explicitly to either card or to the system's default.
However, not all motherboards are set up like this. My laptop has only one sound card that controls both the speakers and the headphone jack. When the headphone jack is plugged in, the hardware automatically disables the built-in speakers, and when it's unplugged it automatically enables them. I have no way of controlling this from the software because it's functionality that's implemented in the hardware.