At 5 months she does not have entire control of the bladder/bowels. Getting there, but she would be in the category of "partially" housebroken. On top of it, she is probably teething and that just messes every thing up.
Here are some housebreaking tips:
1. ANY change in activity means a trip outside. Sleep, eat, drink, play and out.
2. Be there with her and tell her to potty and when she does big party, maybe even a treat. My girl sheltie likes to hold it. She learned "peecookie" as a command because if she pees she gets a cookie.
3. When you return inside you need to either crate, confine in the room with you, or tether the dog to you. If the dog changes activity or even looks like she might be looking for a place to void then out you go.
4. If there is a error that you catch in the process, things like NO and STOP are OK as interrupters but you don't get angry or put the nose in it. Even slightly after the fact, they know that is their urine, wail like you are heartbroken. They know they did that, punishment is not helpful but knowing it upset you is. Clean it up, take the soiled stuff outside and toss it on the ground and say "here, this goes here" and encourage the dog to potty while you are out there and party about it. If you just silently clean it up the dog doesn't get the sense it was wrong. I mean don't yell at the dog and punish it, it's just a baby, but I liked wailing like I was mourning the end of the world and really fast the dog understood he let me down. My very first dog was a 2 year old Aussie who was outside more than inside probably before I adopted him. He was housebroken mostly. I was not experienced with dogs. He peed on the carpet and I started bawling and sobbing and telling him that maybe I would have to take him back to the shelter (I wouldn't have) and he never did it again. He was a smart and loving adult, but I have always utilized that tactic with the pups rather than anger.
People tend to have the most trouble around this age. When the pup was tiny and slept most of the time you carried the tyke out after waking up for a piddle and then back to sleepy or playing with a toy or cuddling. When you get this more active age but not in full mental or physical control of the bodily functions, you have to increase the going out. My shepherd pup and my sheltie, I swear, had to go out every 20 minutes at this age. This is where every mistake sets you back and every correct potty advances you. It's very important to give the dog plenty of opportunities to get it right at this age while helping preventing getting it wrong.