Remember when the angel Gabriel visited Mary, his words included:
He will be great and will be called the Son of the Most High. The Lord God will give him the throne of his father David, 33 and he will reign over Jacob’s descendants forever; his kingdom will never end.”
And Mary responds:
34 “How will this be,” Mary asked the angel, “since I am a virgin?”
But she doesn't say, "How will this be, since I'm not of the house of David?"
It's important that Mary be of the house of David, but it's also important that his adoptive father, Joseph, also be of the house of David as well: his ancestors have a more solid connection to the royal line. You'll notice there are two different genealogies: one in Matthew 1, one in Luke 3.
Matthew was written with a Jewish audience in mind. It traces the genealogy from Abraham to David through Solomon, who was David's legal successor, and ends with:
16 and Jacob the father of Joseph, the husband of Mary, and Mary was the mother of Jesus who is called the Messiah.
Luke, though, was writing with a Greek audience in mind, and traces Jesus' physical lineage to David through Nathan, who obviously didn't succeed his father as king. This starts with:
23 Now Jesus himself was about thirty years old when he began his ministry. He was the son, so it was thought, of Joseph, who was of Heli...
where scholars tend to think that it means Joseph was the son-in-law of Heli, rather than physically related to him, due to the original Greek phrasing. So that brings up the question of was-Mary's-father-Heli-or-Joachim?, but I don't know enough about Anglicized--ancient-Hebrew-names to go off on that tangent.
Anyhow, if you go back to your Jeremiah, you've got a big long angry passage:
24 “As surely as I live,” declares the LORD, “even if you, Jehoiachin[c] son of Jehoiakim king of Judah, were a signet ring on my right hand, I would still pull you off. 25 I will deliver you into the hands of those who want to kill you, those you fear—Nebuchadnezzar king of Babylon and the Babylonians.[d] 26 I will hurl you and the mother who gave you birth into another country, where neither of you was born, and there you both will die. 27 You will never come back to the land you long to return to.”
28 Is this man Jehoiachin a despised, broken pot,
an object no one wants?
Why will he and his children be hurled out,
cast into a land they do not know?
29 O land, land, land,
hear the word of the LORD!
30 This is what the LORD says:
“Record this man as if childless,
a man who will not prosper in his lifetime,
for none of his offspring will prosper,
none will sit on the throne of David
or rule anymore in Judah.”
So, God was able to keep his curse intact: Joseph was related to Jeconiah, but Jesus was never physically related to him. And yet, through Joseph, Jesus was able to connect himself to the major royal line of David. And at the same time, he was still technically of the House of David, since Mary fulfilled that qualification on her own by being David's direct descendant, albeit through a less significant branch of the family.