Not really. Onions will probably only irritate your scalp further and aggravate the itching and not kill the lice anyway. There are shampoos that help treat head lice completely but can be prescribed only after a physical examination .
Visit an allopathic dermatologist near you . Before you choose your dermatologist read this http://www.skinmatra.com/single-post/2016/07/03/Skin-Troubles-Here-is-WHAT-NOT-TO-DO
Do not try to self treat with the shampoos available in the market. You will only be delaying your treatment in that case.