An important factor to consider is the racial strength of your troops. Mortalens will need fewer numbers for defense than Securan. Low maintenance make swarms of robotic troops useful as well, though considerably less so since the introduction of troop research in Shadows. Do not overlook bonuses from troop-related research. The higher your research, the fewer troops you'll need. Underground bunkers, for example, are great for high-priority colonies where you would otherwise station a half-dozen or more troops, and allow you to cut these numbers in half for a small annual fee.
This said it is advantageous to think in terms of troop strength instead of numbers. Colony populations will add to defensive troop strength, but only if there is a troop unit present. I will generally leave a single troop on newer colonies, or none at all until there is reason to protect it. On colonies with a couple billion, I like to maintain around 30-45k strength. On larger colonies near borders I will maintain 60-90k.
These are basic defensive numbers for early-mid game, and by mid-game I will keep a handful of 50-100k+ groups on reserve with nearby transport fleets on hub colonies. These can be rushed around to defend where needed, used as a peripheral invasion force, or called in to a major ground offensive elsewhere. I do not like to keep reserves in space; these can be suddenly and easily wiped out before managing escape, costing recruitment and transport time, ships, and possibly experienced troops and generals.
Home-worlds are another matter. You are guaranteed extensive population defenses at first, so don't overdo it. By the time you need to worry about invasion, you should have a powerful port (ALWAYS set all armed station behavior to "ALL WEAPONS") and maybe a defensive base or two. Otherwise just watch how rival empires are massing troops. I have won home-worlds with early game-blitzes, but the AI doesn't really bother with you until mid-game, even on "restless". Generally rivals will mass lots of troops before declaring; follow their lead if you are playing a defensive strategy. By mid-game I am very comfortable with 90-120k or less, but once the action starts this should begin doubling. By late-game you will know what to expect and can plan accordingly.
Also note that any pirate bases will defend your colonies if invaded. These can be quite powerful if you don't mind the activity until you get the resources to drop more troop units.