Never.
Not in work, for obvious reasons, but also not in non-work code, because my non-work code is seen by a lot more people than my work code, so I feel its even MORE important to act professional there. I also never swear or joke in comments either.
Honestly, I think swearing in commits/comments does nothing to benefit you/code/commits/project.