Since fluorine is more electronegative than oxygen, the oxidation state of oxygen is positive and is +2 in OF2.
⇒ 2×(−1) + x =0
⇒ x = +2
The fluorine is more electronegative and has an oxidation state of -1. In this case, the oxygen has an oxidation state of +2. The oxidation for each fluorine is negative, and the combined oxidation number for two fluorine is negative two. Therefore, to balance the charges, oxygen has a +2 oxidation state.