Does this happen every time you use headphones? Or was this the first time you've used headphones?
It almost sounds to me like a hardware problem... the little headphone jack 'senses' when headphones have been inserted, and then when the headphones are removed, the sensor should know that too. If that little headphone jack has a problem, i.e. if it is loose or the sort, then the little metal contact could be moving around making an intermittent contact, which would make the software think that headphones are being inserted and removed frequently.
Assuming you're talking about headphones with a physical cable. If you're talking about bluetooth headphones, try disabling bluetooth for a bit and see if that helps.
She who laughs last -- probably made a back-up.