Suppose you consistently praise your puppy for their actions, while potty training. Then say your dog has an accident. Do not praise you dog immediately. Instead, take your dog outside and wait for it to go to the bathroom. When it finishes doing its business, take it inside, and keep it in a separate room while you clean up the mess. After this you should act disappointed in your dog, but only for a few minutes. Keep you and your dog motivated to potty train.
Young puppies can’t hold their bowels & bladders for long. If you come home to find that they’ve had an accident in there it’s quite possible that they can’t hold it that long. Generally puppies can hold their bladder for about one hour per month of age. So your 3 month old pup can probably only hold their bladder for about 3 hours. If you’re going to be away at work for long periods of time see if you can get a neighbor, relative or dog sitter to come over to let your pup out during the day.
Consistency is crucial. This may mean taking time off work to be there to take the pup outside every 20-30 minutes when they are awake. Crate training will also help the 'penny drop' as it teaches the pup to hold on until taken outside. Then, be sure to stay with the pup in the yard so you are there to reinforce how clever they are when they do go in the right place.
The process is the exactly same for older dogs as it is for puppies; prevent accidents from happening by using baby gates and a crate if possible, create a predictable schedule, learn to recognize your dog’s potty signals, accompany your dog outside and immediately reward for all outdoor elimination, properly clean any accidents and supervise your dog until you’re sure that he understands the rules.