My first home brew beer is ready to be bottled but I've been busy and haven't gotten around to it yet. The beer was in a primary fermenter for 2 weeks, then I racked it into a secondary fermenter (carboy with airlock) where it has been for about 3 weeks now. Do I need to bottle it immediately or can it sit in the secondary for another week or so?
Let it ride for as long as you want. Keep in mind that the beer is aging and depending on its style and storage temp it may peak in flavor while you are off doing other things.
As long as you protect it from light and keep it as cool as possible (<70F-75F-ish) it should be fine.
The best thing for storing beer in a carboy would also be to ensure there was an shot of CO2 on the surface after you racked it into secondary. But unless you are a kegger already you may not have that option.
Well now, it all depends on your sanitation! If you were careful and sanitary while a) cooling your wort, b) racking to primary, and c) racking to secondary, the beer can stay in secondary for a lot longer than you think! Lagering and cold conditioning are basically long-term secondaries, after all.
Just keep the temperatures low and keep it protected from light, and make sure the airlock stays full - it's easy to forget about that when it's been sitting for a few weeks. Happened to a carboy of a beautiful cherry-smoked hefe I brewed once...well, I'm guessing that it would've been beautiful, because by the time I got to it it smelled like old gym socks.
Personal pet peeve with the term "secondary fermentation" - except for really big beers, there is rarely any fermentation happening in secondary. I like to call it brightening or conditioning, but I'm weird like that.
As long as you want.
As with anything, there are considerations:
Hop Flavor and Aroma
This is a big one. Hop compounds break down and dissipate extremely quickly. If you want a fresh hop flavor and/or aroma in the finished product you need to serve the beer ASAP. Age doesn't impact the bittering nearly as much, however.
The second consideration with hops is that you do not want your beer to become lightstruck (skunked.) The carboy should be stored in a dark location to avoid that smelly rodent from rearing it's ugly head.
Yeast Autolysis & Astringency - Racking off of the trub
If you plan on extended aging in a carboy, you want as little trub as possible. Aged trub will contain dead yeast cells (which cause meaty & brewers yeasty vitamin flavors) and hop particles (which can cause an oversteeped teabag astringency that can completely kill a beer.)
For extended aging, you want to use the smallest carboy you can fit your liquid into. This reduces the liquid's total surface area exposed to oxygen (and total head space - which reduces the total oxygen possible.) Preferably, you want to remove the oxygen somehow (by adding a layer of CO2, for example) because this is going to have a big impact on flavor quite quickly. For some styles, such as an English Old Ale, this is okay because oxidation does miraculous things to the malt character. For most styles, however, the last thing you want is a mouth full of wet cardboard.
Others have pointed this out, but honestly I don't think it it is as big of a factor. Contaminations work pretty quick and if your beer is contaminated it probably won't matter how long you age it. After a couple weeks you will taste it.
That said, if you are trying to contaminate the beer on purpose, that's a whole other story. Assuming the bacteria has something to eat and the alcohol & hops aren't too potent, age helps instead of hindering in production. Bugs turn things on their head though... for example you need oxygen for Brett to prosper.
As Jim answered earlier, with good sanitation, you can leave your beer in secondary for nearly as long as you want. However, if your beer continues to ferment, this will likely affect the finish of your brew depending on factors such as yeast type, temperature stability, and the specific gravity of your beer when you decided to transfer it from your primary. Also, any sediment can and will affect the flavor of the brew. Neither issue are problems as such. Just something to keep in mind depending on the beer style you are brewing, and the flavors that you are aiming for. Some pale ales taste better (subjectively) with a little sediment and cloud in them, but this would not be as desirable in your carefully crafted Pils.
In the end, it's really boils down to whatever it is that floats your beery boat! ;-)
I had a Belgian triple kit from Williams brew, Bavarian yeast, that I left in a carboy secondary for 5 months. Recipe called for about three weeks. It's supposed to bottle condition. I could see some slow fermentation going on initially. Then I could just tell there was positive pressure on the air lock. I figured that meant I had some CO2 formation month one and was sealed. Why I didn't bottle, laziness, didn't want to bother. One day the airlock was empty the water had gotten sucked back into the brew. I added more and it poured straight through the lock into the carboy. I figured I had pushed it as far as I should. Everything seemed normal when I bottled and the brew was clear but I'm bottle conditioning, that isn't necessarily a good thing, also this was an 8.5% kit. After bottling carbonation was supposed to be done in 9 days, opened one up and it was very flat, had a kick to it but a no notable fizz. I did tests and the carbonation time was more like a month. The beer did cloud up which a Belgian should do and very little yeast sediment at all when empty. It was good stuff, really good. So you can go a while.