If you fill the keg carefully, following the correct procedures, then it will "keep" just as long as it would have if you had bottled it. How long that is depends on the style of beer, some benefit from aging, some suffer from it.
But a 3 gallon keg? I have a hard time picturing that lasting long enough to "over age" any beer. And it DEFINITELY won't last long enough for the beer to go "bad".
If you follow good sanitation procedures, no beer, of any style, will ever go "bad", in the sense that you can't drink it. It will taste better and better as it approaches its peak, and then the taste will decline from there. But it will never spoil in the sense that a pound of hamburger will....
It'll always be decent beer, it just might not be as good as it could have been if you wait too long.
But in my house a 3 gallon keg would last about 2 days, so I have a hard time even imagining why one would be concerned about such a small amount of beer having a chance to go bad.....