On a gasoline engine, an oxygen sensor is used to ensure that the proper air fuel ratio is reaching the engine.
Some automobile manufacturers recommend that oxygen sensors should be replaced once every 100,000 miles whether they are working or not. However, this can be very expensive, especially since many newer cars and trucks have up to 4 different O2 sensors.
Usually, a check engine light will provide the first indication that you might have a bad O2 sensor. Often, the engine code will simply state that there is a problem with the O2 Sensor, or it may say that there is a “heater circuit malfunction.”
Since O2 sensors can be very expensive and the problem might not be with the oxygen sensor itself, but could be several other factors, it is a good idea to test your O2 sensor before replacing it.