While O2 sensors have no fixed replacement schedule, your driving style and the health of other engine components can drastically affect its life span.
P2238 is a Bank 1 O2 sensor which is easily fixed with a new sensor, however P0420 is related to faulty or substandard coating on the catalytic converter and firmware upgrade.