Onions are not part of a normal diet for a dog - in other words don't feed your dog onions, raw or cooked.
Garlic on the other hand, can be added to feed - but obviously not in big quantities. I have baked liver, sprinked with garlic powder, as treats for our lot for years. With no ill effects - in fact they love it!!