Thrush

How do you avoid getting thrush? Baby seems to always get it. It comes and goes. Is it hurting my baby?