Control according to the amount of oxygen that is stored on the exhaust gas treating apparatus