get some basic maintenance done and go from there, make sure the filters are new, plugs are good and gaped right, plug wires and in working order, run some fuel injector cleaner and scan for pending code and see if it leads to anything
but I agree the O2 sensor or cat monitoring sensor might be on the way out