It depends on what type of property you are thinking of buying. For single family homes, as always, the towns with top rated schools and good public transportation & amenities will hold their value best, and appreciate in a good market. Locations with a shortage of single families and a vibrant social scene, like Davis and Porter Sqs in Somerville, should do well and have already begun to appreciate.
It's not generally a good idea to buy a single family home or condo with the idea of trying to make a profit in 5 years. When you figure in financing costs, maintenance and sales commissions you'll need about 10% appreciation just to break even. It's a little different if you're buying a fixer upper and want to put in some sweat equity. In most cases you should buy a home because it's somewhere you want to live, and look on capital appreciation as a bonus.
For condos, multi family and investment property stay near the T, preferably the Red Line from Boston north to Arlington, or near a respected college. The Somerville Green Line expansion through Union Sq and Winter Hill is expected to raise values in the neighborhoods near the proposed stations. I wouldn't want to gamble on this being completed in 5 years, though.
A rising tide raises all ships, so it could easily happen that as the market improves many towns experience increasing values. From an investment point of view, however, the safest bet is to stick to the areas I just described.
A good buyer agent who's familiar with investment strategies can help you tremendously. Don't forget, the profit is made when you buy, not when you sell.