Dogs mark the territory both inside and outside the house to let the other dogs know that that's their space and tells the other dogs to avoid the area when they sniff where they marked.
You can stop your dog by marking their territory in the house by getting the dog spayed or neutered which usually solves the problem.
You can also spray the area your dog marks with a pet urine odor enzyme cleaner and let it fully dry which will eventually stop the dog from marking his territory in that area.
Also if you catch the dog about to mark their territory in the house you tell them sternly not to do that and spray them in the face with a bottle of water.
They'll eventually get the hint that they're not to mark their territory in the house.