Did God's curse on Cain extend to only Cain, Cain's descendants or to everyone? When God cursed Cain for killing Abel, did that curse extend to Cain's offspring, to Cain alone, or to everyone? God tells Cain:


  "And now you are cursed from the ground, which has opened its mouth to receive your brother's blood from your hand. When you work the ground, it shall no longer yield to you its strength. You shall be a fugitive and a wanderer on the earth.” Genesis 4:11-12 ESV


Later in Genesis, when tracing the genealogy of Cain's younger brother Seth, this next verse seems to indicate that the ground was cursed for everyone, not just Cain or his direct descendants?


  "When Lamech had lived 182 years, he fathered a son and called his name Noah, saying, “Out of the ground that the Lord has cursed, this one shall bring us relief from our work and from the painful toil of our hands.” Genesis 5:28-29
I think you're talking about two separate curses in your question.

The first curse, the curse on the ground, God inflicted on the entire earth because of Adam's sin:


  
  Genesis 3:17-19 And to Adam he said,“Because you have listened to the voice of your wife and have eaten of the tree of which I commanded you, ‘You shall not eat of it,’ cursed is the ground because of you; in pain you shall eat of it all the days of your life; thorns and thistles it shall bring forth for you; and you shall eat the plants of the field. By the sweat of your face you shall eat bread, till you return to the ground, for out of it you were taken; for you are dust, and to dust you shall return.”
  


Whereas before Adam and Eve were meant to be alive forever and till the beautiful garden, now they must work the ground with sweat and toil. This is the first curse and applies to the entire earth.

The second curse is the one meant for Cain when God says that the ground will never produce food (strength) for him


  
  Genesis 4:10-12 And the Lord said, “What have you done? The voice of your brother's blood is crying to me from the ground. And now you are cursed from the ground, which has opened its mouth to receive your brother's blood from your hand. When you work the ground, it shall no longer yield to you its strength. You shall be a fugitive and a wanderer on the earth.”
  


It's important to note how God describes Cain's new forced way of life as one of a fugitive or wanderer, the Hebrew being nuwa and nuwd which both mean a kind of aimless wanderer. If the ground that he would toil would never bring forth food for him then he will be forced to wander endlessly for sustenance.

Regarding the reference to the cursed ground in Genesis 5:


  
  Genesis 5:28-29 When Lamech had lived 182 years, he fathered a son and called his name Noah, saying, “Out of the ground that the Lord has cursed, this one shall bring us relief from our work and from the painful toil of our hands.”
  


It's natural to assume that Lamech is referring to first curse brought forth by Adam, not the curse that God had applied specifically to Cain.