I'm assuming that what you are saying is that while the headphone is plugged in to the computer, it still plays on the computer speakers.
Most likely, the headphone outlet is dirty and need cleaning. To solve this, plug in your headphones into the headphone outlet, and take it out really quickly. Do this for a certain amount of time until it works.
If this does not work, check the settings if you are allowing it to play into external devices or not.
~