In general the use of offensive words, when not directed against a specific person, can free us from feeling anger or frustration.
Studies have shown that there are situations when it is acceptable, and even healthy to use foul language in relation to the retention of anger. The results showed that swearing increases pain tolerance.
In the experiment, 64 students should keep one hand in a bucket of ice as long as they can. When students repeated a chosen curse, they managed to keep the hand in a bucket for 140 seconds, but when they were not allowed to curse, they endured only for 70 seconds.
As long as your words are not directed against anyone, swearing can be cathartic, because by the use of offensive words we can relieve the feeling of anger or frustration.
Also, swearing creates the feeling as if you have things under control, even when it is not so because it can increase confidence and provide an incentive for further measures to be taken.
If you are nervous because, for example, you are waiting 20 minutes to reach technical support of your telecom operator, try to swear, because you will then have the feeling that you control the situation, and since many systems are programmed to detect vulgarity, you may be quickly connected to the first free operator.