I usually do 2 weeks in the fermenter- until the beer is finished for at least a few days and is clear. Then I keg.
It will last a long long time in a keg- a keg is just a really big bottle when you think about it. Since you dispense with c02, and the beer is protected from light, it will last as long as a bottle would, or even a tad bit longer.
Some beers are best drunk fresh, while others need a bit of age. It really depends on the beer.
Broken Leg Brewery
Giving beer a leg to stand on since 2006