The short answer
For most tanks, an aquarium filter should run all the time. Keep planned shutdowns short, ideally an hour or two, and keep the media wet while the filter is off.
Why the filter needs to run
Biological media depends on water flow. Flow carries oxygen, and the ammonia and nitrite that bacteria feed on, to the surfaces where the bacteria live. Stop the flow, and the colony can start to suffer. Flow also moves water at the surface, which helps gas exchange.
Mechanical media works differently and only needs running while it is catching debris. Most filters combine mechanical and biological media, so the simplest approach is to run the whole unit continuously.
How long can it be off?
There is no firm number. A shutdown of an hour or two during maintenance is the common advice, as long as the media stays wet. Longer outages risk losing part of the bacterial colony. Some guides warn about die-off after several hours, but the timing depends on the tank, the temperature and the media, so treat any single figure as a rough guide.
Power cuts and restarts
A long power cut stops the flow for as long as it lasts. When the filter restarts, the colony may be weaker than before, and ammonia can rise. After an outage, test for ammonia and nitrite, watch the fish for gasping at the surface or unusual hiding, and do a water change if the numbers climb.
Maintenance shutdowns
When you clean the filter, unplug it, work quickly, and keep the media submerged in water from the tank. Restart the filter as soon as you can. For the cleaning steps, see how to clean aquarium filter without killing bacteria.
Quieter nights without switching off
If the filter is loud at night, reduce the flow instead of turning it off. A canister’s flow control valve, if the model has one, is the easiest way to do that. Avoid timers that switch the filter off for long stretches. If the sound is the real problem, the causes are covered in why is my aquarium filter making noise, and fixing the cause is a better answer than switching off.