Exactly why some individuals suffer from food intolerances remains a bit of a mystery. Symptoms may range in severity and may occur in foods that previously caused no trouble. They also often occur with foods that are commonly used in a person's diet. The symptoms may also alternate in terms of frequency: so one day you get this reaction, and on another you do not.
The best way to deal with this condition is by excluding onions from your diet as much as possible you are able and see if this reduces the frequency of your sensitivity symptoms. If indeed your symptoms are greatly reduced or disappear, you can later try to gradually reintroduce onion into your diet by starting with very small quantities after a month of excluding it. Initially, go for foods that contain cooked onion rather than consuming raw onion, because the vegetable is most likely to contain the most potent form of whatever compound that is causing you intolerance.
It is possible to overcome or greatly reduce your intolerance to a food if you exclude it for long enough and then reintroduce it slowly and eat it in smaller quantities than before.