You just need to take the quotation marks off the header name, other than that the iRule is good - but I've tidied it a bit further for you;
when HTTP_REQUEST {
if { ([string tolower [HTTP::header Accept-Encoding] contains "gzip"]) or ([string tolower [HTTP::header Accept-Encoding] contains "deflate"]) } {
pool Test_pool
log local0. "Compression enabled request has been routed [HTTP::header "Accept-Encoding"]"
return
}
else {
HTTP::respond 500 Content "PLEASE SEND A GZIP ENABLED REQUEST" noserver Content-Type "text/html" Connection "Close"
log local0. "Non-Compression enabled request has NOT been routed [HTTP::header "Accept-Encoding"]: "
}
}