Optimum number = number of colonizable planets you can sustain
This number is not constant, as it fluctuates according to your resource demands, fleet size (and capacity), proximity to hostile strongholds, available resources, and numerous other factors.
You should only colonize a planet once you can afford to upgrade it to generate positive income, otherwise it becomes a drain on your resources. Defenses should scale according to the threat you percieve is posed by Pirates or opposing factions (all you need is to buy enough time for a fleet to save the planet). Remember that increasing fleet capacity imposes a percentage reduction on your overall income, so upgrading too quickly will cause your economy to collapse and make it significantly more difficult to raise income rates.
In short, keep expanding, but at a pace which doesn't cause your economy to suffer or spread your fleets out too thinly.