Character is Everything
"Do you swear in your writing?" is not really the apt question. It is more illuminating to ask, "Do my characters swear?"
Some do. Some don't.
My story "Rideshare" follows an angry, shallow, and lonely young corporate type . Here he is, drunkenly offering his Uber driver money to hang out with him:
“Look… Luis—glad your fucking nametag’s there—Luis, Bill Murray is the coolest guy in the world. Hands down. There’s this night out in LA, Bill Murray is going to a club or a movie or wherever the fuck a Bill Murray goes, and he takes this cab and the driver says he plays the saxophone, but Bill Murray talks to him and learns that he never gets the time to play. So Bill Murray says, drive to your apartment and get your fucking saxophone, and then they drove to a parking lot someplace and Bill Murray pays this guy for a whole night so he can just listen to him fucking play the saxophone on the hood of the cab. Now I’m not as cool as fucking Bill Murray, but I got some cash, man. How much you make in a night?”
He's glib. He's boastful. He makes a show of how impressive and manly he is because he tries, desperately, not to reveal what he really feels. (Full story here: https://www.sleetmagazine.com/selected/love_v13n2.html) He swears the way a child would, peppering his speech with an excess of profanity that does not make him as tough as he thinks. The Uber driver never swears once. He is a family man, empathetic and grounded. They are different people; if they are to be real, they need to talk differently.
By way of contrast, here's William Mumler in my yet-unpublished novel, justifying his practice of photographing people with deceased spirits:
Mumler watched the flame, coming forth steadily from the brass.
“Jonah told as destined. He gave the people the message they needed from the Lord,” Mumler said. “The Almighty knows all: my sins, your sins, what will become of us, what would become of Jonah and the Ninevites. Though He knew He would spare the city, He suffered Jonah to spread the message of its destruction. A small untruth in service of a greater truth.”
He appealed to Guay’s unmoving face. “Prophets must serve the truth. That is what I have learned. One cannot choose to be a prophet, Mr. Guay. One cannot choose even the details of the message. The truth chooses the prophet. There are spirits, manifesting in this new age. We must serve that truth, or we will be swallowed.”
If a profane syllable left that man's tongue, his entire character would crumble like a clay-footed statue. In a moment of crisis that could destroy everything he holds dear, my Mumler might use the word "damn," though if anyone heard, he would feel shame.
The character, the narrative, the style determine the language I use in my writing. I am perfectly content to write an academic analysis, or to drop an f-bomb if it makes a joke funnier. I'll write that businessman out on a bender or that photographer who reads his Bible nightly. My task is to write them true.