The relevant rule is Rule 12.1.3:
(a) if the football touches an Umpire or any Official and then passes over the Goal or Behind Line, a Goal or Behind, as the case may be, shall still be recorded;
(b) if the football touches an Umpire or any Official and does not pass over the Goal or Behind Line, the football shall remain in play