What is the make and model of the laptop? From that we can determine the most recent drivers available for the audio chipset, which as ToineF has alluded to, control jack detection for the headphone and microphone jacks. Most often without jack detection, the audio chipset streams audio over both internal and external connections simultaneously and as they are controlled as one device, you won’t be able to shut one or the other off. It is also possible that in the audio driver’s control software there is an option to enable or disable connectivity by port manually, even if jack detection isn’t supported.
You can also potentially select which devices have playback through the Windows Sound Control Panel. Right click on the speaker icon in the system tray and select Playback Devices. From this screen you can enable or disable any device listed. If speakers and headphones are separate, you can simply disable speakers here.