In Matthew, and a few other places in Scripture, Jesus is referred to as the Son of David. The question arises, "How could this be" and then "what does this mean"? To answer this question I would like to give a rather long explanation found on the website preceptaustin https://www.preceptaustin.org/matthew-15-commentary . Read below.
Answer: Seventeen verses in the New Testament describe Jesus as the “son of David.” But the question arises, how could Jesus be the son of David if David lived approximately 1,000 years before Jesus? The answer is that Christ (the Messiah) was the fulfillment of the prophecy of the seed of David (2 Samuel 7:12–16). Jesus is the promised Messiah, which means He had to be of the lineage of David. Matthew 1 gives the genealogical proof that Jesus, in His humanity, was a direct descendant of Abraham and David through Joseph, Jesus’ legal father. The genealogy in Luke 3 traces Jesus’ lineage through His mother, Mary. Jesus is a descendant of David by adoption through Joseph and by blood through Mary. “As to his earthly life [Christ Jesus] was a descendant of David” (Romans 1:3).
Primarily, the title “Son of David” is more than a statement of physical genealogy. It is a Messianic title. When people referred to Jesus as the Son of David, they meant that He was the long-awaited Deliverer, the fulfillment of the Old Testament prophecies.
Jesus was addressed as “Lord, thou son of David” several times by people who, by faith, were seeking mercy or healing. The woman whose daughter was being tormented by a demon (Matthew 15:22) and the two blind men by the wayside (Matthew 20:30) all cried out to the Son of David for help. The titles of honor they gave Him declared their faith in Him. Calling Him “Lord” expressed their sense of His deity, dominion, and power, and calling Him “Son of David,” expressed their faith that He was the Messiah.
The Pharisees understood exactly what the people meant when they called Jesus “Son of David.” But, unlike those who cried out in faith, the Pharisees were so blinded by their own pride that they couldn’t see what the blind beggars could see—that here was the Messiah they had supposedly been waiting for all their lives. They hated Jesus because He wouldn’t give them the honor they thought they deserved, so when they heard the people hailing Jesus as the Savior, they became enraged (Matthew 21:15) and plotted to destroy Him (Luke 19:47).
Jesus further confounded the scribes and Pharisees by asking them to explain the meaning of this very title: how could it be that the Messiah is the son of David when David himself refers to Him as “my Lord” (Mark 12:35–37; cf. Psalm 110:1)? The teachers of the Law couldn’t answer the question. Jesus thereby exposed the Jewish leaders’ ineptitude as teachers and their ignorance of what the Old Testament taught as to the true nature of the Messiah, further alienating them from Him.
Jesus’ point in asking the question of Mark 12:35 was that the Messiah is more than the physical son of David. If He is David’s Lord, He must be greater than David. As Jesus says in Revelation 22:16, “I am the Root and the Offspring of David.” That is, He is both the Creator of David and the Descendant of David. Only the Son of God made flesh could say that. (Source - GotQuestions.org)
In colclusion, the title "Son of David" could be rightly attributed to Jesus Chirst. For physically He was the hear of King David. Being the heir he fulfilled the prophecies concerning David's throne. And He also prophetically fulfilled the requirements for the Messiah.
The Jesus we learn of in the Bible, is David's Heir and David's Lord all at the same time.