Nowdays "onion oil" seems to be the newest darling of hair care enthusiasts. But what is the truth and what is the science behind it? Let's take a look.
Onions have only 0.1 % fat. Oil is 100% fat. Therefore it is virtually impossible (or completely impractical) to extract oil from onion. So the term onion oil is simply a misleading marketing gimmick. What they mean is some base oil (like coconut or sesame) which is infused or boiled with cut oinions. Is that good for our hair? In theory yes. Onions contain a lot of healthy nutrients (including natural sulfur, vitamin C and folate) that do a lot of good for the scalp. But for it to do good to your hair and scalp, both the onion and the oil must be grown organically.
Chemically grown onions have a lot of chemicals and residual poisons which can actually damage your hair. The Phytojournal lists Mancozeb, Carbendazim and Copperoxychloride as the three main chemicals used to manage bulb rot of onion 
The Cedar Circle, a farm and education non-profit, has this to report about onion farming:
"We analyzed the 169 pesticides used on onions and found that 54.5% of the pesticides were highly toxic fumigants. Only nine chemicals accounted for almost 80% of total pesticide use. As with the other crops analyzed in this brief presentation, the most used pesticides were among the most deadly and dangerous poisons." 
Also the big brands that promote so called "onion hair oil" make no claims of organic onions or for that matter organic base oils. As an organic farmer I know from personal experience that onion is among the most challenging crops to grow organically and get an economic and commercially viable yield. I think it is better to use simple organic coconut oil than chemically sprayed onion oil.
More over onion juice helps only in fighting alopecia areata , an autoimmune temporary baldness (see picture). For loss of hair due to heridity or age, there is no cure - we can only prevent further hair loss by good hair care.
So in conclusion, if you are very particular about onion hair oil, it is better to buy some organic oil (from a local trusted source) and organic onions and make your own hair oil at home. If you are in Tamilnadu I would recommend https://purvanaturals.com and https://ofmtn.in as personally known and reliable sources of organic coconut oil.
Organic Farming and Local Economies
(The writer of this article is a well known organic farmer praticing organic farming since 2003)