This is a common allusion made particularly in reference to people in power. This is based more on legend than on mythology.
Damocles was an excessively flattering courtier in the court of Dionysius II, a tyrant in Syracuse, Italy during the 4th century. He praised Dionysius and would exclaim how wonderful it must be to be a man of such wealth and power.
Dionysius offered to switch places with him for a day so that Damocles could experience what it was like to have such power. Damocles gladly jumped at the chance to experience the luxury which he so envied, and he took full advantage of the offer.
At a great banquet, he allowed himself to be pampered like a king. Only after he had finished eating, he happened to gaze up and to see a sharp sword dangling directly above his head by only a single strand of horse hair, but he was unable to move. Immediately, he asked leave of Dionysius, having lost his taste for the food and the fine company.
This allusion is used to make the point that people in power are always under some sort of peril. More broadly, it can refer to any situation that is extremely precarious, or full of impending danger; particularly if the situation can be set off by a delicate trigger.
Can you think of any settings in which you could use this allusion?