Let's compare the following two sentences:
Ich habe gern Spinnen in der Wohnung.
Ich habe Spinnen in der Wohnung gern.
On the first look both sentences contain the same words - only in a different order.
However on the second look only the first sentence contains the verb "haben" and the adverb "gern".
The second sentence contains the verb "gernhaben" which is a separable verb. "Separable verb" means that the verb is separated into two parts in certain tenses: "gern-" and "-haben".
In all cases of separable verbs I know both parts are valid German words on their own but the meaning of the separable verb often has nothing to do with the meaning of each part: "gern-haben" has nothing to do with "haben"; "ab-hauen" has two meanings; one of them neither has to do with "ab" nor with "hauen".
To make it even more complicated:
German language allows you putting adverbs at the end of the sentence. So the second sentence may have the same meaning as the first one - however most native speakers would not understand the sentence this way.
Now let's get back to your sentences:
Ich habe das Haus gern.
In this case we have the separable verb "gernhaben".
Ich wohne gern in diesem Haus.
In this case "gern" is an adverb.