com perl
:
perl -0777 -lne 'print for grep !/DOG/, /^HEADER.*?TAIL.*?\n/mgs' your-file
com awk
:
awk '! inside {if (/^HEADER/) {inside = 1; skip = 0; content = ""} else next}
/DOG/{skip = 1; next}
! skip {content=content $0 "\n"}
/^TAIL/ {if (!skip) printf "%s", content; inside = 0}' your-file