Excretion is the removal of metabolic waste products such as carbon dioxide, urea, and nitrogenous compounds through organs like the lungs, kidneys, skin, and liver.
Defecation is the elimination of solid waste from the gastrointestinal tract, consisting mainly of undigested food, bacteria, and mucus, through the rectum and anus.
In short, excretion removes metabolic waste, while defecation eliminates digestive waste.