It may be caused by relatively high pressure. It is suggested that when you are depressed, you should properly adjust the time of work, study and rest, set the time of exercise, and often relax your nerves.
Reducing stress and maintaining a good mood in other healthy ways is the fundamental way to improve your swearing.