In oxygen difluoride $\left( OF _2\right)$ and dioxygen difluoride $\left( O _2 F _2\right)$, fluorine gains electron with negative charge as $F$ is more electronegative than $O$. Thus, $O$ will have positive charge.
$\therefore$ Oxidation number of $O$ in $O F_2=+2$
$\therefore$ Oxidation number of $O$ in $O_2 F_2=+1$