(a) OH⁻ has 6 (O) + 1 (H) + 1 (charge) = 8 valence electrons. Oxygen forms one single bond with hydrogen and keeps three lone pairs, so it has an octet and hydrogen has a duplet. The Lewis structure is written as [H–O]⁻ with three lone pairs on oxygen, the whole ion enclosed in square brackets with the charge outside.
Formal charge on O = 6 − 6 − ½(2) = −1.
(b) HF also has 8 valence electrons, arranged in the same way: one H–F bond and three lone pairs on fluorine. Formal charge on F = 7 − 6 − ½(2) = 0, and on H = 1 − 0 − ½(2) = 0, so HF is a neutral molecule. Oxygen has one valence electron fewer than fluorine but is surrounded by the same eight electrons, so it carries a formal charge of −1, while hydrogen in OH⁻ is still 0. The negative charge of the hydroxide ion is therefore located on the oxygen atom.