Gravity is *always* there and always points vertically downward. So it doesn't always point towards the centre of the circle, but most of the time, some component of it does, and that component contributes to the centripetal force.
Centripetal force is not a physical force that is present in addition to the other forces, gravity and tension. Rather, centripetal force is merely a *kinematic requirement*: IF the object is moving in uniform circular motion at radius r with speed v, THEN there must be a net force on the object equal in magnitude to mv^2 / r. However, this net centripetal force must be a result of some of the physical forces that are present in the problem, and if these forces cease to be available to *provide* a centripetal force, then the object will cease to be in circular motion.
In this problem, the forces summing vectorially to *provide* the centripetal force are gravity and the tension in the string. As I mentioned before, gravity always points vertically downward, which means that its "centripetal" component varies with the position of the mass in the circle. When the mass is at the top of the circle, it happens that "vertically downward" and "towards the centre of the circle" are the same thing. In other words, ALL of the gravitational force points centripetally, and gravity can contribute *maximally* to the centripetal force at this point. So, at this point in the circle, it may be the case that you don't NEED any tension to provide the necessary centripetal force for that circular motion. All of it can be provided by gravity. If that's the case, then the tension will go to zero at this instant. The condition for not needing any tension is simply that the available force from gravity is greater than the required centripetal force for the circular motion:
mg ≥ mv2/r
g ≥ v2/r = ac
So as long as ac ≤ g, gravity will be more than enough to provide the centripetal force at the top of the circle, and no additional contribution from tension will be required. But if you spin the object faster (or in a tighter circle) such that ac > g, then it will be the case that gravity won't be enough to provide the centripetal force at any point in the circle, and the string will always be under tension to provide the shortfall.
EDIT: as voko pointed out, we actually need ac >= mg, else there is no circular motion because the string goes slack. But everything else I said holds. If ac = mg, the string tension goes to zero at the top of the loop.