Create Script from Bash Script using here-document; why does my variable get replaced?

Here document by default subjects to shell expansions, precisely parameter expansion, command substitution, and arithmetic expansion. So variable (parameter) expansion is happening in your case -- the variable LOGFILE is being expanded in the current shell, and as the variable presumably does not exist hence null is being returned (and replaced) as the expanded value.

To get the shell metacharacters literally in a here doc, use quotes around the terminator string:

cat pippo <<'EOF'  ## "EOF" would do too
LOGFILE=test.log    
echo '#############################' >>"$LOGFILE"
EOF

Also quote the variable expansion as (presumably) it refers to a filename, so that word splitting and pathname expansion are not done on it after expansion.