How do you replace the headlight bulb located on a 1998 Mazda 626?

This answer applies ONLY to replacing the headlamp bulb, not the entire headlamp assembly. The work is done with the hood of the car up. It requires good lighting under the hood. Locate the 3-wire bundle that leads to the bulb; those wires terminate in a plastic connector that is attached to the back of the bulb. As you view the connector from the top, you should see a compressible clip on each side of the connector. These clips are somewhat recessed into the connector so locating them may require some study. Once you have located the clips, depress them with your fingers and withdraw the connector from the bulb. Both the passenger's side and driver's side installations are very confined so removing the connector may take several tries. With the connector disconnected from the bulb, remove the black rubber boot (cover) that protects the bulb assembly. You should be able to see that the bulb is held in place by a wire clip and the wire clip is held in place by a Phillips head screw. Study the installation of the clip before removing it (perhaps even draw a diagram) because it is not obvious how it goes back in place. Loosen, but DO NOT REMOVE, the screw. Squeeze the wire clip with your fingers so that the side of the clip not secured by the screw is released from a recess in the bulb housing (opposite from the screw). Install the new bulb by reversing the procedure outlined above.

In addition to the above, before you remove the 3-wire connector, you will save yourself much aggravation if you remove other parts that are blocking the plastic connector. On the passenger side, there is a small plastic radiator overflow tank. It is easily removed by removing the 2 Phillips screws that hold it in place. On the driver's side, you will need to remove a plastic air intake tube. It is held in place by 2 Phillips screws, as well as a hose clamp.