Some earbuds come with cases that can help prevent tangles, but many dont.

it’s possible for you to then wrap the length of the cord around the cork.