At https://phys.org/print413432138.html … why do comets expel oxygen? It was first encountered in early 2015, and previously was unknown (or that is what is implied). It was revealed in the data received from Comet Churyumov-Gerasimenko via the Rosetta Mission. It was discovered as a component of the comet's atmosphere, or coma. We don't know if oxygen is a component in the atmosphere's of other comets but it may be. The paper, in Nature Cummunications (May 2017), suggests water vapour molecules stream off a comet as it is heated by the Sun. They become ionised, or charged, by ultra-violet light from the Sun, and the solar wind blows the ionisedwater molecules back towards the surface of the comet. When they collide with the surface they interact with oxygen in sand and form O2. The oxygen molecules need not be primordial as mainstream has believed until this hypothesis was aired, but may form in situ (which is the main point made. See also www.sciencenews.org/article/oxygen-comet-67p-might-not-be-ancient-after-all
However, not all scientists think it is a plausible theory as O2 is abundant on the comet. Data from the mission showed that as the comet approached the Sun a protective bubble developed, preventing solar wind particles or other ionised particles from reach the comet's surface. Also, the ratio of oxygen to non ionised water seemed to stay much the same over time.