That's what the bottoms of sock are for! Just launder and live with a certain amount of grunginess. They'll be clean enough to wear, and the same thing will just happen again anyway.
It's a shame to waste resources, and cotton requires great amounts of water and energy to grow and process. So I wouldn't toss them. And it's a shame to poison the wastewater stream with chlorine or other strong cleaners. Those chemicals can't all be removed before that water returns to the environment that our children and grandchildren will grow up in.
If you feel too obsessive about spotlessness to live with it, I hope you'll at least donate the stained socks to a shelter.