Are they white and mostly cotton? If white, wash them separately with a bit of bleach in the wash water.
If they are colored, also wash a small load separate from other garments and use powdered color-safe bleach as directed.
If they're white and you've a place to dry them outside on a line or laid out on the grass, the sun will help whiten them.
Another good tip about socks (anklets or knee socks) is to buy at LEAST two pairs of the same size and color at one time. That way, with luck, the socks may wear out one at a time and you have a chance of still having a matched pair for a longer length of time.
If you soak socks and or underwear in hydrogen peroxide for 10 to 20 minutes. Then wash regularly with laundry soap then rinse with a little vinegar there will be no athletes foot or other germs left and your clothes will be cleaner!