It is generally accepted that the poem of Job (chapters 3–41) remained largely intact during its copying process, but in the prose framework (chapters 1–2 and 42) more revisions may have occurred. It is easier to modify prose, because it usually has less layers of meaning and one does not need to deal with syntactic/semantic parallelism or the inner structure of a poem.
It is thus possible that an older version did not contain 42:1–6, and "these words" in 42:7 referred to the whole divine speech (chapters 38–41). There would be good reason for someone in later times to add 42:1–6 in. In 42:7, God says, "my servant Job has spoken of me what is right". A later editor may have found this incomprehensible or offensive, because of Job's earlier criticism (the Judaic religion became stricter in that sense). Hence, this later editor would have inserted 42:1–6 so that the "right thing" that Job said about God now refers to Job's repenting.
Having said that, in more orthodox circles people sometimes suggest that "these things" refers to something not expressed in the text. This has the methodological advantage of not having to assume a textual history that you cannot prove. A famous example is in the binding of Isaac (Gen. 22:1), where "these things" appears at the beginning of a storyline:
After these things God tested Abraham and said to him, “Abraham!” And he said, “Here I am.” (ESV)
Rashi's comment lists two suggestions, that "these things" refers to words spoken by either Satan or Ishmael:
Some of our Sages say (Sanh. 89b) [that this happened]: after the words [translating “devarim” as “words”] of Satan, who was accusing and saying, “Of every feast that Abraham made, he did not sacrifice before You one bull or one ram!” He [God] said to him, “Does he do anything but for his son? Yet, if I were to say to him, ‘Sacrifice him before Me,’ he would not withhold [him].” And some say,“ after the words of Ishmael,” who was boasting to Isaac that he was circumcised at the age of thirteen, and he did not protest. Isaac said to him,“ With one organ you intimidate me? If the Holy One, blessed be He, said to me, ‘Sacrifice yourself before Me,’ I would not hold back.” - Cf. Gen. Rabbah 55:4.
I am however not aware of similar discussions around Job 42:7. Rashi does not comment on "these things" there; presumably, he does not find it a problem that "these" refers back to chapters 38–41 while 42:1–6 is interposed.