An interesting question. Psalm 102 is a lament-style poem. That, in and of itself, does not preclude the possibility that it can have messianic elements. So, let us look at the actual passage that the Hebrew writer appears to be quoting. In Psalm 102:24, the person writing the lament says, “Do not take me away, my God, in the midst of my days. Your years go on through all generations.” Then he says to God, “In the beginning you laid the foundation of the earth, and the heavens are the work of your hands….” It is true that in this lament a person is talking to God. But here is the question: Who inspired this Psalm? Who speaks in the entire Scripture? God inspires all of Scripture. Therefore, through this person, God is revealing things about himself. We can allow the writer of Hebrews a little poetic license when he tells us that through Psalm 102:25-27 God is telling us something about his Son. I can see why you ask this question. It is a logical quandary, but it is not evidence of an error in the Bible. It is true that in this Psalm it is not literally true that God is saying this, but is true that God is saying this in that he inspired the Psalmist to say this about his Son.