While Dottard answered this question, this is how I would organize the answer.
Jesus’ statement was not so much a contradiction as stating that worship was about to change. Jesus continued:
”You worship what you do not know; we worship what we know, for salvation is from the Jews. But the hour is coming, and is now here, when the true worshipers will worship the Father in spirit and truth, for the Father is seeking such people to worship him. God is spirit, and those who worship him must worship in spirit and truth.” (John 4:22–24, ESV)
But, how do we apply Deut. 12:5 under the new covenant? In Deut. 12:5 ”His habitation” is לְשִׁכְנ֥וֹ, an infinitive with the root (lemma) שׁכן and the 3rd person masculine singular suffix. This verb is a discussion in itself. A relevant passage is John 1:14:
And the Word became flesh and dwelt among us, and we have seen his glory, glory as of the only Son from the Father, full of grace and truth. (John 1:14, ESV)
The word dwelt translates ἐσκήνωσεν from the verb σκηνόω. What is striking about this verb is it sounds the same and has the same meaning as שׁכן. These words apparently have the same etymology, although TDNT has the etymology of σκηνόω as uncertain, probably because it is a very old Greek word. BDB traces שׁכן all the way back to Akkadian cuneiform, šakânu. So, the connection would be before those languages were written.
The glory of the LORD is the subject of the verb שׁכן at mount Sinai (Exodus 24:16). The glory of the LORD was visible to sanction the Tabernacle (Exodus 40:35) and Temple (1 Kings 8:11–12).
Deut. 12:5 concerns sacrifices, “and there you shall bring your burnt offerings and your sacrifices…” (Deut. 12:6). Jesus was crucified (our sacrifice), buried, and raised (John 19&20) outside Jerusalem. He ascended in Jerusalem, and the Holy Spirit arrived at Penticost in Jerusalem (Acts 1&2). Thus, Jesus was the final fulfillment of Deut. 12:5. As Jesus said, “Do not think that I have come to abolish the Law or the Prophets; I have not come to abolish them but to fulfill them.” (Matt. 5:17, ESV)