Like so many questionable bits of scientific misinformation, the claim that putting onions on your feet will do something unspecified that has to do with "toxins" is repeated with similar or identical language on many different web sites.
One site that has given this concept undue attention is that of David ‘Avocado’ Wolfe, a prolific purveyor of misinterpreted science and blenders. He explains the basic rationale in a November 2016 post:
The Chinese found that there are thousands of tiny nerve endings on the bottom of the feet. These nerve endings act as access points to the internal organs. They are also closely linked to the nervous system. Onions have strong anti-bacterial and anti-viral properties. When you cut an onion and place it on the bottom of the foot, it gets right to work removing toxins and healing your body.
If that explanation isn’t doing it for you, Wolfe provides additional reasoning as well. But, like a desperate student called on in class after a heavy night of not studying, Wolfe lists numerous unrelated, disconnected, illogical, and wholly inaccurate claims about how an onions on your feet might impart a health benefit in the hopes that the sheer volume of answers will not betray his own lack of knowledge.
Only three of these five explanations hold even a modicum of relevance to the onion sock theory:
Onions detox the body – Onions are rich in sulphuric compounds. These compounds are responsible for their strong odor. Sulfer [sic] helps the body release unwanted toxins, especially in the liver.
Onions purify your blood – While the onion is next to your foot, phosphoric acid is released. It enters your bloodstream and helps to purify the blood running through your veins. [...]
Onions support the immune system – Thanks to the anti-bacterial and anti-viral properties of onions, your immune system becomes better prepared to fight off infections and inflammation. [...]
With these claims in place, we can get a general picture of how Wolfe and others suggest this works: Borrowing from the Traditional Chinese Medicine concept of meridians, the feet are a gateway to multiple organ systems in your body which allow chemicals from the onion to enter your bloodstream like a portal, where they get to purifying, bacteria killing, and virus fighting.
First off, the existence of meridians have not been demonstrated scientifically, and even if they had been, practitioners of Traditional Chinese Medicine describe their action as transporting energy or “qi”, not as transporting actual physical compounds, so Wolfe’s description of the mechanism by which beneficial onion compounds make it to your body is not off to a great start.
Ignoring this problematic beginning, the next claim refers to an onion’s sulphuric compounds. They do indeed exist, and they have indeed been proposed as the primary chemicals responsible for an onion's medicinal benefits. A 2002 review in the journal Phytotherapy describes these chemicals and lists their potential health effects:
Onions are rich in two chemical groups that have perceived benefits to human health. These are the flavonoids and the alk(en)yl cysteine sulphoxides (ACSOs). [...]. The ACSOs are the flavour precursors, which, when cleaved by the enzyme alliinase, generate the characteristic odour and taste of onion.
The downstream products are a complex mixture of [sulfur-based compounds]. Compounds from onion have been reported to have a range of health benefits which include anticarcinogenic properties, antiplatelet activity, antithrombotic activity, antiasthmatic and antibiotic effects.
Unfortunately for proponents of onion foot therapy, these potential benefits all necessitate the ingestion of these compounds, not passively leaving the entity responsible for their creation in close proximity to one's foot. Ultimately, this kind of reasoning is a lazy distraction, equating the benefits of ingestion with other less plausible, and often undefined, pathways.
While there have been some limited studies regarding some of these (ingested) benefits in laboratory settings, it needs to be noted that there has been little research definitively showing these effects on humans (though there is also a lack of research in general on the topic), per that same review:
Clearly there are many claims on health benefits of Alliums [the genus that includes Onions], however, most, with the exception of garlic, have not received any rigorous (or even gentle) scientific investigation
Further, the notion that these sulfur-based chemicals “release” toxins is vague oversimplification. The argument could be made that the antioxidant properties of some onion chemicals aid in the cleansing of “toxins” from your body, but, again, you would need to be ingesting said chemicals.
In the same vein as releasing toxins is the notion that the phosphoric acid found in onions cleanses your blood. The inclusion of this pro-phosphoric acid statement is odd for a David Wolfe page, given the fact that he rails against the chemical on his other pages.
Though there are myriad problems with the idea that phosphoric acid cleanses your blood and with the notion that topical application of it on your foot would have any effect whatsoever, all of these issues are irrelevant as onions do not contain phosphoric acid to begin with.
In fact, phosphoric acid is used in laboratory settings to liberate compounds from onions and garlic for analysis. Every so often, alarm bells are sounded on food blogs about the inclusion of phosphoric acid as a preservative in minced packages of (the closely related) garlic. Needless to say, the lack of phosphoric acid in onions is another serious blow to the proffered theories for why sock onions could have medicinal properties.
In terms of the onion’s ability to boost your immune system through their antibacterial and antiviral compounds there are two ways to look at it: Yes, onions have been shown in laboratory settings to fight both viruses as well as bacteria and conceivably, these compounds could have a benefit to you — but, again, only when ingested.
In this case, as well, the topical application of some chemicals in onions could kill bacteria externally. However, just as the ingestion of onions will not reduce external bacterial infections, neither will a topical application be effective at creating any change to the internal systems of one’s body, as claimed.
All things considered, the evidence presented to support this fairly outlandish notion is either false or misleading, and we cannot find any plausible mechanism for a raw cut onion stuffed in your sock to reduce any disease.