The length of time to keep your lights will depend on the type of aquarium you have running. For a freshwater tank with just fish there really is no set time. Anywhere from 1-12 hours per day will be fine. If the tank is in an area where it gets lots of indirect sunlight or simply is a bright room you can keep the lights on for less time. If it is a very dark room you can keep the lights on longer. This will also hold true for a fish only saltwater tank. The longer you keep the lights on, the more algae can grow in the tank. So if you find you are getting heavy growths of algae you can simply cut back on the amount of time the light is on and/or add algae eaters.
If you have a freshwater planted tank or a reef aquarium most people recommend running your lights for 8-12 hours per day. This should give your plants or corals plenty of time for photosynthesis.
No matter what type of tank you have the use of a timer to turn on and off your lights is recommended. Fish and invertebrates will do much better when they have a regular schedule of when the lights are coming on and going off.
Here is an article about things to know about lighting that might also help out some.