Personally, I am used to washing my underwear and socks separately. However, if you are used to putting the two together, it is okay, but I recommend you do the following to ensure personal health and hygiene.
First, different colors of underwear and socks should be avoided to clean together.
Second, underwear and socks of different materials should be avoided to avoid mixing together.
Third, remember to regularly clean the washing machine, disinfection.
Just make sure to follow the rule of sorting:
Sort laundry by color
Sort laundry by fabric
Sort laundry by level of soiling
(The laundry bag can effectively prevent the clothing from winding together, and prevent the clothing from wearing and deforming. It's also more hygienic.)
Make sure to have a load depending on the sorted items. For white clothes like socks and undergarments you can bleach. Although soap does a decent job but to be more cautious for clothes which may have more chances of bacterial invasion use bleach.