Install step flashing against a wall or other vertical element, like a chimney, after the roof decking and underlayment are installed but before shingles are added. Get flashing at least 8 inches wide, to allow at least 4 inches up the wall and 4 inches down the roof. Use flat metal flashing and bend it yourself or buy preformed flashing at a 90-degree angle.
Run the step flashing up the wall under the siding. Slide it under already installed siding if possible -- otherwise remove the bottom layer of siding material to accommodate the step flashing. Fasten it to the wall sheathing only with galvanized roofing nails and a hammer -- do not nail it to the roof decking, but seal that side with roofing cement. Put nails high enough that the wall siding will cover them. Use two nail positions if possible, one high and one low.
Add a "kick out" at the bottom of the roof, to guide water running down the roof away from the wall. Buy a preformed type or make one yourself from basic step flashing. Extend a portion of the wall side flashing over the edge of the roof. Cut it with tin snips at the angle. Bend the part on the roof down over the edge of the roof edge. Bend the side along the roof over the roof as a barrier, so water running down the seam where roof and wall meet will be diverted onto the roof. Fasten these pieces with roof cement.
Put counter flashing against a brick wall or chimney, where siding cannot cover the top of the step flashing. Place the top side of the counter flashing into mortar joint or into a slot cut into the bricks and run the other side down over the top of the step flashing. Bend counter flashing around a wall corner or corners of a chimney to seal the step flashing.