When exiting the ladder on a climb to the roof, the ladder rails should extend a full 3′ past the height you’ve climbed. This allows you to have the rails within reach, so you can hold on to them and have a rung very close to the edge of the roof as you transition between the ladder and roof and back again. On most two-story homes, this can only be done with a 28′ extension ladder. (This 3′ extension rule also holds true indoors and for shorter heights like one-story dwellings; you’ll just need a shorter ladder.)
Alternatively, if you have no plans to get on the roof, a 24′ ladder will typically get you to the eaves of a two-story house for painting, window repair, and other items along the sidewall. However, it’s not unheard of for folks to misuse ladders when unintended situations arise. “Nah, I’ll never need to go on the roof,” you think—until a hurricane deposits a tree branch there, or blows off shingles so it’s raining in your bedroom. Next thing you know, you’re bouncing up your (undersized) ladder because it’s an emergency. If there’s a scintilla of a chance you’ll go topside, my advice is to buy up. Better to have it and not need it than to need it and not have it.