If I plan to add anything during fermentation such as dry hops, cacao nibs, etc, I'll secondary.
Otherwise, my rule of thumb is three weeks. If I plan to wait more than three weeks to bottle or keg, I want to get it off the yeast, so I'll transfer to secondary as soon as fermentation is done.