it should stay locked. Maybe the socket has been overused, meaning optical plugged and unplugged too many times?
have you taken off the plastic tip on the optical cable?
i suppose you can try a different optical cable to make sure.
I just bought an optical audio cable and it never stay is the plug. This happens on both components I'm trying to connect. The plug just pops out. Should it 'lock' into place or be more snug? Did I buy the wrong kind?

Chowhound
Comic Vine
GameFAQs
GameSpot
Giant Bomb
TechRepublic