Ginger should generally be added *after* the tempering of spices in oil. This prevents it from burning quickly and allows its flavor to infuse gently into the oil.
Tempering involves heating spices in oil to release their aroma and flavor. Spices like cumin, mustard seeds, and asafoetida are typically added first. Ginger, being more delicate, can burn easily if added at the same time. Adding it after the initial spices have tempered allows the oil to cool slightly, preventing the ginger from scorching. This method ensures that the ginger's flavor is extracted without becoming bitter or acrid. The gentle heat will still allow the ginger to release its aromatic compounds and contribute its characteristic warmth to the dish. The timing also depends on the form of ginger used. Finely grated or minced ginger is more prone to burning than sliced ginger.
If using ginger-garlic paste, add it after the initial tempering spices and cook on low heat, stirring frequently, to prevent sticking and burning. A splash of water can also help to deglaze the pan and prevent burning.