Compounds without charge always have a total oxidation number of zero.
Then you follow the rules in assigning oxidation states: FHO765 (order of precedence), and their respective values in order are -1, +1, -2, -1, -2, -3.
Take acetic acid, for instance (CH3-COOH)
C-C bonds are equally electronegative, therefore in accounting their oxidation state, they have no effect on each other.
hydrogens take precedence over everything else in the molecule, therefore assign +1 to all Hs.
oxygens are next in the order of precedence, therefore assign -2 to all Os.
calculate the oxidation state of the methyl carbon: it is bound to 3 hydrogens (+1 * 3 = +3), therefore it has an oxidation state of -3 (must sum to 0).
calculate the oxidation state of the carboxylic acid carbon: it is bound to 2 oxygens (one of which has a -2 oxidation state, and the other bound to a hydrogen has a -1 oxidation state (-2 + 1 = -1), therefore this carbon has an oxidation state of +3 (must sum to 0).