It generally takes 1-2 weeks following COVID-19 vaccination for the body to build immunity against the virus.
Duration of protection differs per vaccine and may be influenced by who receives it. People who are immunocompromised tend to develop a weaker immune response to the standard number of vaccines doses, and therefore need an additional dose in the primary series. Immunity against mild infection starts to wane in the months following vaccination, especially among older adults. This is why many countries have introduced a booster dose, starting with the older age groups.
Update (March 2023):
The booster dose policy in countries is evolving. For current WHO booster recommendations see: