If you're writing for young children, then bad language is just not okay. When it comes to writing for Young Adults, swearing is allowed, so long as the themes of your novel demand it and you're writing for the more mature YA audience (that is, one likely to be making its own book selections).