There are numerous stories regarding the origin of onion in
Hinduism and some of the give the reason why onion is considered as non-vegetarian by certain Hindu communities. This particular story is associated with Vedic Yajnas.
During the Satya Yuga, Sages performed Gomedha Yajna (cow sacrifice) and Ashvamedha Yajna (horse sacrifice) for the welfare of the people. During the course of the yajna, a cow or horse was sacrificed. At the culmination of the Yajna, the same cow or horse was brought back to life by the Rishis through mantras but with a younger body.
During the Satya Yuga, Sages performed Gomedha Yajna (cow sacrifice) and Ashvamedha Yajna (horse sacrifice) for the welfare of the people. During the course of the yajna, a cow or horse was sacrificed. At the culmination of the Yajna, the same cow or horse was brought back to life by the Rishis through mantras but with a younger body.
Once, a sage was performing Gomedha Yajna. The wife of the
sage was pregnant and she desired to eat meat. She believed that if a pregnant
woman had a desire to eat and did not eat then the child born will always have saliva
coming out of the mouth.
So when the cow was sacrificed, she took a small piece of
meat and hid it.
Soon the sacrifice ended and the Rishi chanted mantras and
brought back the cow to life but he soon noticed that a small piece of flesh
was missing from the left side of the cow.
The wife of the Sage realized that soon her husband will
find out the truth through his yogic powers. She therefore threw away the piece
of meat.
But the piece of meat had life in it due to the mantras
chanted by the sage. In due course of time, the piece of meat became onion.
Thus onion is avoided by some Hindus as it is considered non-vegetarian.