First off... if you examined where your audio header connects to your motherboard, you will most likely find that you don't only have left and right Out, as well as ground connections for each, but that you also have left and right In.
Image courtesy of Intel (believe it or not).
With some header connectors, there are just two loops (red and white usually, but not always) of wire from the out pin to the return pin.
Image Courtesy of bjorn3d.com
However... the whole reason for this out/return setup is simple, and it sounds like your case is making use of it. Better quality cases use headphone jacks that include a physical "switch" within them.
Found that image on Tomshardware.it
This is simply a contact that is broken when you insert the 3.5mm plug. When that contact is broken, no return signal is sent to the motherboard, so no audio is sent to the rear speaker port. When the headphone plug is removed from the front jack, the connection is re-established, so the audio signal is sent once again to the return pins, and thus to the rear audio out port.
In newer/better quality motherboards, this can be controlled via software... where if you are using a program that can interact properly with your audio hardware and drivers, you can actually tell the software whether to send audio to the headphones, or the speakers. However, this functionality all depends on having the most up to date drivers, a motherboard that has audio hardware that offers this functionality, and software that offers the ability to send audio to different outputs.
From what you say and show, you are dealing with a hardware function only. You could try to update your drivers, and you can see if you are given "expert" or "advanced" options...
but it is just as likely (if not more so) that it is just the design of your case front audio header and your specific motherboard that switches your speakers on and off depending on the presence of something plugged in the front.