Man avoids jail after punching dog in head before trying to