It depends on what type of beer it is, and why it's in a secondary to begin with. If it's an average gravity beer and you racked it to clear it, then a couple weeks is fine. If it's a big beer and you're bulk aging it, then it could be months or years. I have a 17% abv barleywine that spent nearly two years in a secondary and then went into a barrel to age for another year, I'm getting ready to bottle it and leave it for another 2 years....
You also don't need to rack it to a secondary if it's only to let the flavors come together and to clear, many folks skip secondary and opt for an extended month long primary instead. And only use a secondary to add something to the beer, or to clear the beer if something was added to the primary.
If I use a secondary (rare these days) for a beer I tend to rack it after 2 weeks for another 2 weeks, leaving some time on the original yeastcake to allow the yeast to clean up after itself, then rack to let the beer sit on whatever I've added to the secondary.