It has only been the last few years that we have lived in an apartment and been faced with dilemma, with the advent of increased housing density in many cities globally this is a very good question.
Firstly a healthy house trained adult dog has different requirements to a puppy, sick or elderly dog.
Healthy house trained adult dog.
As a bare minimum dogs need to be taken out at least three times a day. Morning when they first wake, as most people know, this is a time the bladder has been accumulating bodily fluids and there is usually the most pressing need to go. During the day, after lunchtime and before bedtime. People (including myself) have successfully homed dogs with this type of routine.
When a dog is taken for such a toilet break, the break needs to include a min-walk at least on each occasion, this allows the dog opportunity to relax and relieve themselves several times before returning inside.
Exceptions to this will be, if the dog indicates it needs to go out, or the dog is unwell, or there has been a change in the feeding routine.
Puppies.
The number of times a puppy needs to be taken out is very age dependent (for this purpose I am assuming that the puppy is actively being house trained). To begin with, young puppies 8-12 weeks age, need to be taken out every time they wake from a nap, after they eat and whenever they sniff around in a manner that indicates they need to relieve themselves.
This can be reduced as they gain bladder control. The biggest thing with puppies is going to the toilet when they wake up from sleep, it seems to be a time when the first thing they want to do is urinate. This is also a key time to help successfully house train a puppy.
Sick dogs.
Depending on the ailment, whether a dog is recovering from surgery or ill in some way, this will usually increase their need to relieve themselves. It is best to go by advice from a Vet and cues from the dog, when they need to relieve themselves. Like puppies, unwell dogs will often need to urinate when they wake from a sleep.
Elderly dogs.
As bladder control is reduced and a dog is unable to hold for either urination or defecation, it is better to take an older dog to the toilet more frequently. To begin with a dog will show signs, by going to the door asking to go out, that they are not coping with a previously successful toileting regime.
So, a dog that previously was happily let out three times a day for the toilet, may start needing two toilet breaks during the day, or an early evening, then late night break. It is something that develops gradually and cannot be definitely said, [this many] breaks is the magic number. The key is to know your dog and read his/her cues.