"Nasty" is not a bad word. It is perfectly good standard English. It can be used in ordinary speech.
It could be used in a work situation: "We're having a nasty problem with defective chips in the Model 1640B."
It could be used in everyday conversation: "I spent the weekend on the beach, and I got a nasty sunburn."
It can be used to describe a person who is mean, or a bully. "Stay away from him, he's a really nasty guy." "She's usually a sweet person, but watch out for her nasty streak."
However, one of the meanings of the word "nasty," (like the word "dirty,") is "immoral, indecent, sexual in a bad way." Depending on the context, the phrase "a nasty girl" might mean a prostitute. Or, it could mean someone who misbehaves sexually in a way that the speaker disapproves of. Of course, slang being what it is, it could also be someone who misbehaves sexually in a way that the speaker _approves_ of.
"Doing the nasty" is a slang expression that means "having sex."