What is meant by the infallibility of the Catholic Church? By the infallibility of the Catholic Church is meant that the Church, by the special assistance of the Holy Ghost, cannot err when it teaches or believes a doctrine of faith or morals.
But the Advocate, the Holy Ghost, whom the Father will send in my name, he will teach you all things, and bring to your mind whatever I have said to you. (John 14:26)
When does the Church teach infallibly? The Church teaches infallibly when it defines, through the Pope alone, as the teacher of all Christians, or through the Pope and the bishops, a doctrine of faith or morals to be held by all the faithful.
Further reading: CCC 888-892