Most cars have pre and post catalytic converter O2 sensors.
If you failed emissions testing, it's likely that it's the pre cat O2 sensor, but that is not an absolute.
Go over to autozone (or some place like that) and have them read the OBD codes from your car. They should indicate which O2 sensor this is. If not, go for the first one.
Please note, be careful with the sensor when installing.
http://www.popularmechanics.com/cars...enance/4219927