A male off-duty police officer has been spared jail after admitting to drunkenly attacking a woman while she was walking home alone.