You are using two different words that only look the same:
- "gernhaben" - to like, a separable verb that in your case forms a bracket around the middle part of the sentence "Ich habe[ das Haus ]gern.
- "gern" - gladly, an adverb that works as an attribute to the verb here. Adverbs are a bit more free with respect to word order, you could also say "Ich wohne in diesem Haus gern"
As the two words are different, and even of different type, they have to follow their respective rules where they go in the sentence.
And, as a kind of challenge: Is the following sentence a grammatically correct German sentence (stilistics excluded)?
Ich habe das Haus gern gern.