At its root, this problem is based in probability. The factors that increase the chance of tangling are both the length of the wire and the amount the headphones are agitated.
The paper is called Spontaneous Knotting of an Agitated String and explains how the fact that headphones are always tangled is the truth instead of just confirmation bias. The researchers took different lengths of cord and put them inside a rotating box to study this.
They found the longest a cord could be without getting tangled is about 46 centimeters (or 1 foot 6 inches). Between 46 cm and 150 cm (that's about 5 feet) the probability of knows forming rises steeply to the point it tops out at about 50%. You can see the shape of this graph to the left.
My headphones are about 5 feet long. Apple's headphones are 139 cm. If this is the average length of headphones, then you have about a 50% chance of pulling them out tangled anyway. The researchers did note that they did not study the Y-shape of the headphones, which probably increases the probability of them tangling anyway - so now we're looking at some number north of 50%.
Interestingly enough, the study did look at how cords could "spontaneously" tangle themselves just because of the way physics works. So, this is really a lose-lose situation. Regardless of what you do, your headphones will probably be more tangled when you take them out than they were when you put them away.