I generally do it about 7-10 days before I bottle or keg. Most of the time I cool the carboy to get my yeast to drop out as much as possible. Take it out - let it warm up to 65 or so again and then insert hops. (i prefer to do everything in one carboy. 4-8 weeks before I transfer)

However - I see people saying to do it a few days after fermentation stops - which seems a bit nuts.

I was actually just looking into this and some of the craft brewers actually dry hop starting as soon as primary fermentation is starting to slow down, but before it has been completed. They leave it in there for a few days to a week then transfer to secondary. I think the theory is that you are still at warmer temperatures so you can extract more oils, plus fermentation is still active, so the yeast "circulate" the hop particles around, rather than them just sitting on the top of your beer.