A rule of thumb for adding spices to foods is to add them in the final minutes of cooking. In the case of soups, stews and sauces the spices are added this way. However, in the case of baked goods this may not be possible; they are added during mixing.
Some spices, such as cumin and coriander, are not too volatile and can be added early in cooking. Others, like cardamom, are delicate and are added near the dish's completion.