The answer to your question depends on a number of things.
However, there are two things you need to do: go to a pet shop and buy a cleaning product specifically for pets and throw away whatever cleaning products you have that are based on ammonia because it smells like urine and it basically means "pee here", then clean the floor thoroughly.
First, how old is your dog? If he's a pup, you'll need to remember that they can't control their bodily functions until they are 3-4 months old and generally need to go out whenever they wake up, which might be every 2-3 hours. If you're away more than a couple of hours, he will do his business on the floor because he can't hold it. If that's the case, you'll need to find a small area for him to stay while you're away and place there his bowl with water and one of the house training mats you can find in pet shops a couple of feet away from the bowl. Hopefully, he'll learn to use that mat while you're away.
Also, let me recommend you Pippa Mattinson's "The Happy Puppy Handbook: Your Definitive Guide to Puppy Care and Early Training". It was recently released but it's by far one of the best books available for new pup owners and it will nicely guide you through puppyhood, including crate training.
If the dog is older, things might get trickier. Normally dogs instinctively know to keep their "den" clean, meaning the area where they eat and sleep, but puppy farms or inexperienced breeders might cause that instinct to go away by locking up a pup in a crate for many hours and forcing the pup to pee and poop right next to his bowl and pretty much in his sleeping area.
I own two dogs and they both learned really fast to do their business outside, but from what I've heard the solution would be to keep an eye on the dog pretty much all the time and when he's starting to smell the ground you should quickly grab him and carry him outside and make a lot of fuss when he's doing his business outside. Hopefully, he'll learn but I've also heard that some adult dogs will still pee and poo inside from time to time.
At the same time, you can't rule out a possible infection and dogs that are ill might not be able to hold it. If that's the case, take him to a vet.