How do you fix your sound when you plug a head phone but then when you take it out it doesnt work wWhy?

Because the connector from your headphones is not in the socket, therefore the audio current cannot travel to your headphone speakers, and the headphone will not emit any noise.