By definition the oxidation number is the charge left on the central atom, when all the bonding pairs of electrons are broken, with the charge, the extra electron, going to the more electronegative atom. Do this for water, #H-O-H#, we gets #O^(2-)#, and #2xxH^+#, i.e. #stackrel(-II)O# and #stackrel(+I)H#. Break the homoelement bond in peroxide, the electrons are conceived to be shared, because the oxygens clearly have equal electronegativity: #HO-OHrarr2xxdotOH#; the oxidation state of the oxygen in the hydroperoxyl radical is CLEARLY #-I#.
And when we do this for #H_3CS(=O)CH_3#, we have Pauling electronegativities of #S=2.58#, whereas #C=2.55#, #H=2.20#, and #O=3.44#. And so we gots #2xx""^+CH_3+""^(-2){S=O}#. The individual oxidation states are therefore, #stackrel(-II)C#, and #stackrel(+I)H#, and #stackrel(0)S#, and #stackrel(-II)O#. Agreed?
But for #"dimethyl sulfide"#, i.e. #(H_3C)_2S# we gots #stackrel(-II)S# and #2xxCH_3^+#, i.e. #stackrel(-II)C#. And so, the sulfur in #DMSO# is indeed oxidized with respect to #"dimethyl sulfide"# (when DMSO is used for sports medicine, it is known as doggy-breath, because it penetrates the skin, and exits the mouth as foul-smelling dimethyl sulfide.)
In both instances the sum of the oxidation numbers equals the charge on the molecule, here ZERO.
Again, we note that oxidation number is a formalism, a label of convenience that does not have real chemical significance.