Many laptops have an option to enable/disable the various sound outputs depending on what is plugged in. For example, on my laptop when I plug in some headphones the headphones socket gets the sound output and the speakers are disabled.
To find this option, right-click on the sound utility in your menu bar, select "Open Volume Control". From here, go to the Edit menu and choose Preferences. There may well be a whole bunch of options that have not been selected... select some. When you click on Close you may find a bunch of new options available to you - one such option might just be something about autosending the headphone socket.