Small leaks around windows – involving cracks and small openings (say, less than 1/4" wide; 5 mm) - can be sealed with common caulks, particularly acrylic and acrylic-latex caulks. These caulks are easy to apply and to wash up with water, and provide a good sealing. They are perfect for indoor uses.
For sealing window joints (aluminum, glass, masonry) you may use silicone and urethane caulks; they perform better.
For larger openings around windows and doors use polyurethane-based one-part foams. They are excellent for rough surfaces and irregular cracks.
When using foams, do not fill the entire opening; fill it partially and expect the foam to expand. And don’t stop until you finish your work.
See, for details: Caulks & Foams
Foams are on average more expensive than caulks. One-part foam canisters may cost you between $5 and $10. Prices of caulks (tubes) range from $1 to $5, according to their type.
Gaskets and Backer Rods
Gaskets are flexible materials especially designed to be used between metal and glass, or other non-flexible materials. They act as thermal breaks.
Spongy foam ropes (backer rods) are designed to fill large gaps between the rough opening and the window frames. They come in various diameters and require adequate caulking.
A DIY job
Window caulking and foaming is a DIY job, easy to perform. You just have to choose the right material and apply it according to the manufacturer’s instructions.
If you have an attic and a basement or crawl space, make sure that they are properly sealed. Otherwise, caulking around windows will not help much.