Some badges (mostly the ones which can be awarded more than once) are awarded fairly quickly once you meet the criteria.  Things like Nice Question, Enlightened, and the like.  These are probably awarded from within the main system, typically triggered by voting activity.

Other badges (mostly the ones which can only be awarded once, like the specialist badges) are awarded by a background process which appears to run only a few times a day.  I don't think the exact times when it runs are known (and may not even be consistent), so it's hard to say.  However, it's safe to say that after 24 hours, if you still don't have your badge, something is amiss.