Loss of smell and taste during a cold or flu is called Anosmia and Anosmia which is a loss of smell and taste is caused by your nasal passages and other airways that allow you to taste and smell being blocked.
The flu or a cold can also mess with your taste buds which allow you to taste things as well so the taste of food can be off when your taste buds are not working correctly during a cold.
Also the swelling of the nose is another cause of losing your ability to smell & taste during a cold, sinus infection, allergic reaction etc.