As you can see above, headlamp bulbs are much different than most of us remember them. Most of the time, people will only replace the one headlamp bulb that is burned out when one fails. However, it is wise to consider replacing both bulbs instead of just one. Remember, they have both been on the same amount of time so a second failure is likely in the near future. Also, replacing just one headlamp bulb can result in an unbalanced headlight beam which can be a bit disconcerting. The road will be lit more brightly on one side than the other and the driver will not receive the full benefit of a lighted roadway as was designed for the vehicle. This is because modern bulbs can lose as much as 30% of their effective brightness within five years.
An unbalanced headlamp beam can also be somewhat distracting to an oncoming driver and could pose a situation where safety is compromised if the driver is confused by what appears to be two different headlights coming at them.
One should bear in mind that there are a number of parts that are recommended to be replaced in pairs. Common items are brake pads and rotors, shocks, wiper blades, tires, etc. Note that all of these are safety related items and your headlamps (or brake lights, tail lights, turn signal bulbs) should be no different.
It is easy to assume that such recommendations are simply a way for the shop to make more money. Please take the time to consider that your safety is always paramount and that replacing bulbs in pairs also prevents a second trip to the shop or even the dreaded traffic stop by law enforcement to inform you of a failed lighting component of your vehicle.