O2 sensors can are a misunderstood subject. First let me explain what exactly they do. In laymen terms it senses the fuel mixture and the temperature of the exhaust gas to determine a few things. One if the car is cold (just started) which means it will need more fuel or not and Two it adjusts the fuel being deliver to the cylinders based on how rich or lean the mix is in the exhaust tube. When the check engine code for this is triggered, it doesn't always mean the sensor is bad. A lot of the time is just clogged up by carbon from low grade fuel and need of a tune up. Here the steps to first remove, clean and re-install the o2 sensor or skip the cleaning if you'd rather just replace it.
We've removed the heat shield to give you a better view. Now, most cars have 2 o2 sensors an "upstream" and a "downstream". Basically it just mean one before and one after the catalytic converter, the reason for the rear one is to determine if the catalytic converter is functioning properly. There are specialty tool and socket that are specifically made to remove these, but most like ours can be done with your standard 7/8 wrench to save money on a tool you'll rarely if ever again use.
To remove simply unplug connector from engine/body harness. Place wrench on the O2 sensor and turn counter clockwise(left) to loosen. Then simply unscrew it and remove.
Now, I highly recommend trying to clean it before replacing it, these are extremely durable sensors and 9 times out of ten are just dirty. To clean simple use a carb cleaner or a parts cleaner to blast the debris from the inside of the unit and a rag to remove the outer debris.
Then simply reverse the remove, screw in to exhaust and snug down. Do not over tighten it.