On this page of the Valheim game guide, you will learn where to find onions.
Onions are a new vegetable type added to the game in the Hearth & Home update. They are required to cook the new recipes. You can find onion seeds in the Mountain biome. They are inside crates located in abandoned buildings.
Then, you need to grow the vegetable itself. The cultivation process itself is no different from other plants - use the cultivator, prepare the soil (more on this topic can be found on a separate page of this guide). You can plant onions without issues even in the Meadows biome.