How often does a O2 sensor need to be replaced on a Toyota Highlander 6 cylinder?

When the computer throws the code that you need to change the sensor.