You generally don't want to use shell loops to do text processing. Here, I'd use awk:
export H
awk 'NR == 7 {
s = ENVIRON["H"]
gsub(/,/, ") or\n host(", s)
print " host(" s ")"}
{print}' file
Like GNU sed has that -i option for in-place editing, GNU awk (since 4.1.0) has -i /usr/share/awk/inplace.awk¹ as an equivalent.
If you want to edit a text file, one could argue that you should use a text editor. With vim, you could implement the same approach with:
export H
vim -esc '
let @a=$H
6put a
s/.*/host(&)/
s/,/) or\rhost(/g
x' file
¹ do not use -i inplace as gawk tries to load the inplace extension (as inplace or inplace.awk) from the current working directory first, where someone could have planted malware. The path of the inplace extension supplied with gawk may vary with the system, see the output of gawk 'BEGIN{print ENVIRON["AWKPATH"]}'