Copied from a microsoft support page:
Check if you plugged them into the correct 3.5 mm socket (it's usually a green one). If connected anyplace else, like in an analogue 2.1 socket; they'll be detected as speakers.
Method 1: Run the audio troubleshooter and check. Follow the steps in the article below and then move to the methods mentioned below:
http://windows.microsoft.com/en-us/windows7/Open-the-Playing-Audio-troubleshooter
Method 2: Check to see if your headphones are set to be used as the default *Communication* device instead of the default device, or if both devices are set to default.
If so, make the headphones default, so that Windows will use them only when they are plugged in.
You can also try disabling whichever one you don't want to be playing.
a. Right click on the speaker icon in taskbar and select ‘volume control options’.
b. Place a check mark on "All devices currently playing sound".
c. Make sure you have "The default communication device unchecked".
d. Place a check mark on both speakers and headphones.
Method 3: Update the audio drivers and check if that helps.
http://windows.microsoft.com/en-US/windows7/Update-a-driver-for-hardware-that-isnt-working-properly