Install step flashing before siding is put on the wall or remove the bottom layer of siding to expose the wall sheathing and moisture barrier. Use step flashing which comes in sections typically about 8 inches long, bent at a 90-degree angle extending 4 inches up the wall and 4 inches over the roof. Fasten it with galvanized shingle nails and a hammer.
Place the first piece of step flashing at the bottom of the roof where it meets the wall. Make a "kickout" on the roof side by cutting a 45-degree angle into the roof side of the flashing with tin snips, cutting from the side of the flashing to the bend. Nail the regular part of flashing to the wall with a shingle nail and bend the cut piece out over the roof, so any water that comes down the wall will be "kicked out" over the roof edge into a gutter.
Put the first layer of shingle over that piece of flashing. Nail another piece of flashing over the top of that shingle, then "step" up the roof, alternating flashing and shingle. Cover each shingle top with flashing and each flashing top with a shingle. Nail flashing to the wall sheathing, never to the roof -- the shingles will hold the flashing in place on the roof.
Step the flashing up the wall to the roof peak. Nail a full piece of flashing so it extends up the wall past the peak. Cut along the 90-degree bend line with tin snips up to the peak. Extend the vertical side of the flashing up the wall past the peak. Bend the roof side of the flashing onto the roof over the peak. Put a bead of roof caulk or cement over the end on the roof. Do the same on the other roof side, so flashing tops overlap on the wall, with bends over the roof peak. Finish that second bent piece with caulk. Seal the peak with cap shingles over both pieces of flashing. Install or re-install siding on the wall.