In high school, my AP English teacher gave us the freedom to choose which book to read individually for our final paper. She tried to push Catcher in the Rye by adding "you'll like it; there's swearing in it." (Despite what you may believe, based on the name of this blog, I did not choose Catcher. I had already read it, so I chose Lord of the Flies.) I remember she specifically added the "swearing" bit because when I had read it I didn't even notice those words were there. I was too wrapped up in the ball of emotion that was Holden Caulfield and the journey through New York City to pay attention to things like that. If he swore at all, then it was as natural and as necessary as any other word.
We often talk about sex in YA, violence in video games, and other things that might not be "appropriate" for our nation's youth. While the question of gratuitous language does come up, it's discussed - on the whole - far less. I should mention that when I talk about "colorful" language in books, I'm not just talking about YA. If anything, teens use curse words way more than adults because, like drinking, adults learn when to hold back, when it's appropriate, and when to indulge.
I bring this up because I was recently reading a manuscript - one that I was excited to begin - and I could not get over how many F-bombs were on the first page. Obviously this narrator was mad. But I didn't know who he was, why I should care, if the person he was angry with really was a "bitch," as he claimed, or even where he was. It felt like I was being bombarded with emotion that I wasn't ready to take on as a reader. The narrator went on to drop this language into conversation, and every time it felt forced and unnatural. Eventually I had to give up on the story because it was so distracting to read.
Certain things are translated differently when they are on the page, which is why, as novelists, you need to be more conscious of the image you project. Writers like Quentin Tarantino and David Mamet don't have to worry about that as much. (If you're familiar with their work, you can probably guess why I chose them as examples.) They aren't writing for the page. In the flash of a single image, their world, setting, and even character can be immediately established. As a result, their characters can say whatever the fuck they want.
Novelists don't have that luxury. Yes, their characters can say whatever they want, but when they can say it matters a little bit more in books than it does in movies. It takes longer to introduce your character and establish a connection to your reader - especially if you're writing in 3rd person. First-person narration might makes things easier since you're establishing your main character's voice right from the beginning. Even still, the reader needs to understand his or her POV before they're forced into it.
Now, lest you think I'm just being prudish about "the devil's words," I'll admit that not all swear words are bad and no one needs to be sheltered from them. Sometimes they need to be added, not taken away. If your character finds himself in some seriously fucked up shit, then he better call it like he sees it. Even the mildest person in the world will let out a quiet "motherfucker!" when they stub their toe. It's natural and sometimes a curse is the only word that can sum up events.
Whether you're writing YA or adult fiction, treat swear words the same way you would any other word. Sometimes they need to get edited out, and sometimes they fit so perfectly that the reader barely notices them. If you're ever in doubt about whether you're being excessive or not excessive enough, just ask yourself two questions: Is this something my character would say? and Does this type of language fit the situation? Like with most things, there are exceptions to rules and ways to bend them, but in most situations, answering these two questions will suffice.
I'm of the mindset that almost everything can be appropriate for all ages if done properly. Why hold anything back if it will resonate with your audience and enrich your story? But make smart choices. Swear words are just words the same way sex and violence are just actions. They each have a slightly heavier weight than their counterparts, sure, but ultimately it's up to you whether your story needs carry it.