Range. There is a whole range from 1/2 hour to weeks or even months (rarely). Fortunately, this is very rare.
There is a list of rare diseases that require antibiotics before dental work. You want to discuss your diseases with your dentist or an internal medicine doc.

Transient, low risk. There is a possibility of a transient bacteremia after minor oral surgery, extraction, gum treatment, etc. But this usually does not cause any problem since your immune system can handle it. But if you are immunologically compromised or have a heart murmur, it is better to be covered with an antibiotic one hour prior to the procedure. Ask your physician or dentist for advise on this.