Mazda suggests the following procedure to remove/service an oxygen sensor without the need to replace the catalytic converter/exhaust pipe.
In some cases the O2 sensor may be seized. If so, remove the converter or pipe from the vehicle and re-attempt removal with the assembly placed in a vise. If you plan to re-use the sensor, mask it with masking tape to prevent lubrication soaking. Spray CRC Freeze-Off or equivalent around the sensor. Allow lubricant to reach the sensor threads for at least 1-2 minutes.
Use offset wrench SST 49 L018 001 to remove the sensor. If stuck, work in alternating clockwise and counterclockwise directions.
Using SST 49 L018 001, turn the sensor 30 degrees counterclockwise. Remove the SST and spray the lubricant again. Allow the lube to penetrate for at least 1-2 minutes. Use the SST to remove the sensor. If the sensor binds, work it in alternating clockwise and counterclockwise directions to slowly work the sensor out. Wipe off all excess lubricant. Clean the O2 sensor threads in the converter or pipe with SST J-43897-18 threading tool. Coat the O2 sensor threads with a high temperature nickel-based anti-seize compound. Remove masking tape and install. Tighten the sensor to 22 – 36 ft-lb.
Use thread cleaning SST J-43897-18 to clean/re-form the female threads.