They say muscles ache after a workout because the workout causes wear and tear of the muscles. Why doesn't the pain start asap ?
It's called Delayed Onset Muscle Soreness (DOMS), but you'll note the Delayed word there. The pain usually shows up 24 hours later and is gone around 72 hours. It's actually not fully understood (2003 analysis in Sports Medicine):
Up to six hypothesised theories have been proposed for the mechanism of DOMS, namely: lactic acid, muscle spasm, connective tissue damage, muscle damage, inflammation and the enzyme efflux theories. However, an integration of two or more theories is likely to explain muscle soreness.
Certain types of activity, particularly lengthening (eccentric), are much more likely to cause DOMS. DOMS is also more likely to be caused by new exercises and new load. On the supplementation side, L-Glutatmine has been shown to reduce the severity of DOMS (but not eliminate it).
One last note is that DOMS is not a good indicator of your workout. As an example, isometric muscle movements are unlikely to cause DOMS, and nearly all heavy back lifts train the lower back muscles isometrically (like the deadlift).
Dumbbell flies will give almost anyone DOMS, and deadlifts will probably not give you much in your back: that doesn't mean that dumbbell flies are better than deadlifts because they make you more sore.