First, you must obliterate any notion that words can be divided into good and bad. Any words can be used to good or bad effect. Curse words are strong words, not bad words, but they are susceptible to being made weak and dumb through overuse. To teach this is far more challenging than it might seem, because every other part of the world in which we seek to raise our children into decent adults is working against you here. And if your children inhabit that world without obedient awareness of the line between good and bad words, they will encounter constant friction.
Too many good lines from this post on Medium by Geoff Barnes about how to teach your kids to curse properly.
One more:
When you do curse, settle for nothing less than your very best. Whether an understated monotone curse or an animated swear fiesta, show respect for the form.
Go read it. And yes, it should go without saying that there are a few swear words in the article.