5 months old is still very young for a puppy to be 100% reliable. And you might want to check at the vet, your puppy could have a UTI, which would make complete housebreaking nearly impossible. Females sometimes have incontinence issues, but not usually until they are older. Either way, a vet check up might be in order.
Puppies at that age need supervision when inside the house and need to be on a schedule (as far as potty breaks and meal times). Do you use a crate or ex-pen while you are gone or can't supervise? If not, you might want to do that until the dog has matured a little bit. Also the use of baby gates is good to block off puppy access to places she doesn’t need to venture unsupervised. That way she can't accidentally eat something that might result in her needing surgery. Puppies learn about their world thru their mouth and sometimes ingest dangerous things that way. The crate is for protection and also for training.
You might think the dog is housebroken b/c the puppy won't use the bathroom in front of you in the house, that is why you supervise so they can't go off and learn bad habits (like using the bathroom somewhere where you won't see and where they won't get in trouble). Don’t blame the puppy, she had to go, and figured that place was as good as any. Most dogs don't know better until taught (although I have had one that was great from day one).
Make sure and praise your puppy when she goes outside, go with her so you know when she has used the bathroom, and make a big deal about it to help her learn right from wrong. You can even give her a treat and play fetch with her after she uses the bathroom in the right place. Also it will help you know how much freedom to give her, if she has already pooped and peed and doesn't have a UTI, she shouldn't need to go again for awhile and that will help you know how closely to watch her for signs she needs to go.
Some people train their dogs to tell them when they need to go with bells, some use doggie doors, some dogs pace in place, one of mine hits the door with her paw to let me know she has to go.
I don't trust my puppies alone in the house for any length of time or to be in another room alone for very long even while I am home (I have been burned too many times, puppies love to use the bathroom and eat things they shouldn't
) until they are about 7-12months old (it varies with each dog though, many take MUCH longer, I have gotten pretty lucky but also put tons of time and energy into teaching them right from day one, even when it is not convenient for me, I know all the hard work in the beginning pays off for years to come).