Puppies should go outside to pee at least every 2 hours since they can't hold in their urine or poop to long.
Adult dogs should go outside at least every 3 hours to pee or poop. Adult dogs are capable of holding in their urine and poop for up to 8 hours but i'ts best to take the dog out to potty sooner than 8 hours if you can.
If you will be gone away from your dog for longer than 8 hours you should have someone come over to take care of the dog while you're gone or take it to a kennel until you get back or take the dog with you if possible.