Why is it rude for men to swear in front of women?

At work, my two make colleagues said they would stop swearing when I got the job because I'm a female. Whenever they do swear they apologize, and they joke with other staff about how they tried to stop swearing for me and failed.

Then today, another member of staff (male) came in and started swearing, then looked at me and instantly apologized.

My brother said he was told that it's rude to swear in front of ladies.

Why is this? Is there a reason or is it just etiquette?
Why is it rude for men to swear in front of women?
Post Opinion