I tend to avoid it, but sometimes I will let my audience overrule me. I did a couple of small google ads that advertised my first novel MagicLand as a "profanity-free zone." I didn't originally write the novel targeting YA, but the characters sort of took over and that's what it became, and there isn't a swear word in it.
My novel Psalm of Vampires is a different story. It has pretty salty characters who swear a lot.
My novel Restive Souls is alternative history set in the early 1800s. I think there's one or two instances of "shit" but that's it. I wrote that novel with the hope it would be read by adults but also young people, and I didn't want parents to shy away from it because of salty lanaguage.
Usually, here on Medium, I only use an F bomb to make a point. Sometimes even several points in one article/essay, lol, especially if humor is involved.
But overall, I think you laid out a really great rule for its use. There is no "fuck" in chocolate. Great writing advice right there.