I agree, P0138 is the code for a bad O2 sensor, the one under the car near the cat.
There's no reason to remove any trim pieces. I haven't done it for a while, but I think there are one or two plastic push pins that tack the carpet to the center hump, you should be able to pry these out with a screw driver, or a pair of needle nose pliers, Then just pull the carpet down from the top to expose the connector
Disconnect the connector, and push the rubber grommet and wire through the floor pan.
No particular special tool needed to remove the O2 sensor from the pipe. They sell special "O2 Sensor Sockets" and the sensor is a metric size,
maybe 22mm, but what I did was take a 7/8 closed end wrench because that's what I had, worked it up the cable and past the rubber grommet. I have also taken them out using a large adjustable crescent wrench. Just make sure it's a good fit, because after so many years and the high heat, the thing will be sort of rusted into place, so you might need to smack the tool with something heavy, like a hammer or a rock, to break the rust. It has standard orientation threads, so make sure you smack it the right direction (to turn it counter clockwise in this picture)
I bought one form one of the chain auto parts stores, Advance Auto or Autozone, but don't remember the part number. Might be different part for base/GT/AWD, but don't remember.