Fortunately, the answer here is quite simple:
In a previous post, I established that it is never legitimate to dissent from the teaching of the Magisterium of the Church - that is, from the teaching of the bishops of the Church collectively (united with the successor of St. Peter, the bishop of Rome) or from the teaching of the bishop of Rome by himself. The thesis of this post follows naturally from that previous thesis (and, indeed, was already included in it), for the reason it is never legitimate to dissent from the teaching of the Church is because the Church has been endowed with the authority of Christ and the guidance of the Holy Spirit, and therefore what the Church teaches is what Christ teaches, and Christ always teaches truth. The only legitimate reason to assent intellectually to a proposition is because there is reason to think that proposition is true. It would be a contradiction and a violation of reason for the Church to demand assent to teaching which she does not at the same time guarantee as truth. This would be to divorce the idea of intellectual assent from the idea of truth, which would be contrary to reason.
I present a more extensive amount of evidence in my previous post, but The Second Vatican Council Dogmatic Constitution Lumen Gentium describes the basic idea concisely:
Among the principal duties of bishops the preaching of the Gospel occupies an eminent place.(39*) For bishops are preachers of the faith, who lead new disciples to Christ, and they are authentic teachers, that is, teachers endowed with the authority of Christ, who preach to the people committed to them the faith they must believe and put into practice, and by the light of the Holy Spirit illustrate that faith. They bring forth from the treasury of Revelation new things and old,(164) making it bear fruit and vigilantly warding off any errors that threaten their flock.(165) Bishops, teaching in communion with the Roman Pontiff, are to be respected by all as witnesses to divine and Catholic truth. In matters of faith and morals, the bishops speak in the name of Christ and the faithful are to accept their teaching and adhere to it with a religious assent. This religious submission of mind and will must be shown in a special way to the authentic magisterium of the Roman Pontiff, even when he is not speaking ex cathedra; that is, it must be shown in such a way that his supreme magisterium is acknowledged with reverence, the judgments made by him are sincerely adhered to, according to his manifest mind and will. His mind and will in the matter may be known either from the character of the documents, from his frequent repetition of the same doctrine, or from his manner of speaking. (Second Vatican Council, Lumen Gentium, #25)
Sometimes there is a misconception that the Church can err that comes from the fact that the Church has different levels of teaching. Sometimes the Church teaches definitively - that is, her teaching is presented with an absolute finality, so that it is to be taken as irreformable. It is not a provisional position that might be altered or even corrected in the future when circumstances change or more information comes to light. Other times, the Church teaches in a less definitive manner, not intending necessarily to be giving the final word on a particular subject. In some such cases, it can be said in some sense that the Church can err, because the Church's teaching can be reformed when circumstances change. But it is crucial to recognize that in such cases, the Church is not truly erring strictly speaking, for she does not intend to teach definitively (just as I have not erred if I declare that there is a 90% probability that a certain event will take place, even if that event ends up not taking place). To the extent that she guarantees her teaching to be true, it is to be taken as indeed true. To the extent that she allows her teaching to be reformable, it is to be taken as reformable. That is what Lumen Gentium is getting at when it says that, even when the pope is speaking non-ex-cathedra (that is, non-definitively), "the judgments made by him [must be] sincerely adhered to, according to his manifest mind and will." If the Church teaches us that some particular claim is definitely true and will always remain true, then we are to accept that this is the way things are. If she teaches in some particular case that a particular claim is the right way to think about something at this time without necessarily guaranteeing that future circumstances will not alter this judgment, then we are to take this as the way things really are. If she teaches us that a certain claim is to be accepted as most probable at this time, then we can be sure that it is indeed most probable at this time. In short, we are to assume, based on our trust in God's guidance of his Church and the authority of Christ speaking through her, that whatever she intends to teach us is always in accordance with truth and will never lead us into error. This is why all her teaching requires "religious assent". So while the Church does not always teach definitively or non-reformably, in the strictest and deepest sense we must say that she cannot err.
There are some Catholics who are under the impression that the Church is only infallible (in this strictest and deepest sense) when she teaches definitively, or even only when she speaks in an ecumenical council or when the pope speaks ex cathedra (that is, when he defines an official doctrine of the Church definitively in a solemn pronouncement), and so we are free to disagree with what she intends to teach us in other cases. But this position, in addition to being contrary to the Church's teaching about her own authority, leads logically to a position that undermines trust in the Church in general and so is fatal to the very foundation of Catholic epistemology, which is dependent on the reliability of the God-guided Magisterium to lead the people of God into truth regarding the interpretation and application of God's revelation in Scripture and Tradition. A fictional dialogue might be one of the best ways to bring this out:
Frank: What do you think of Pope Francis's new teaching on the death penalty?
Thomas: I totally disagree with it.
Frank: But how can you disagree with it? It is teaching from the ordinary magisterium of the pope, and he has placed it in the Catechism of the Catholic Church, making it quite clear that it is official Catholic teaching. We are required to submit to such teaching with religious assent.
Thomas: No, we don't have to submit to it. The pope is only infallible when he makes a definitive judgment. But this new teaching is not definitive. It could therefore be wrong. Therefore, we do not have to submit to it if we think it is wrong. Well, I've looked at the evidence, and it seems to me the teaching is wrong.
Frank: I won't claim the new teaching is necessarily definitive in every respect. It may not be the Church's final word on this subject. But it is still a positive teaching of the Church, and we are to assent to it. Are you saying the Magisterium of the Church can err in its official teaching?
Thomas: Yes, the Church can err in her teaching, when that teaching is not definitive.
Frank: Again, I grant that the Church does not always teach definitively. But you seem to be going further than this. You seem to be saying that the Church can intend to teach something as true to the people of God and yet be wrong about it. It is clear, for example, that the pope intends to teach as true the idea that the death penalty is currently inadmissible, given the state of the world as it currently is and the state of the evidence as it currently exists. Are you saying the pope, and the Magisterium in general, can intend to teach something as true, but be wrong?
Thomas: Yes, exactly, so long as they are not teaching definitively.
Frank: How do you know that the Church can err when she is teaching non-definitively but cannot err when she is teaching definitively?
Thomas: Because that's what the Church herself has said! See the documents of Vatican I and II. See the Catechism. See the statements on this subject from the Congregation for the Doctrine of the Faith. And so on.
Frank: Well, I do not agree with you that the Church has said this. But putting that aside for now, I am more interested in examining your position further. You say that you know the Church can sometimes intend to teach truth but be wrong, because the Church has told you this?
Frank: Well, if the Church can intend to teach truth and be wrong, how do you know she wasn't wrong when she told you that she can be wrong when she teaches non-definitively? How do you know she isn't wrong when she tells you she is infallible when teaching definitively?
Thomas: She can't be wrong about that, because that is definitive teaching!
Frank: But how do you know the Church cannot err in her definitive teaching?
Thomas: Because the Church tells me so!
Frank: But your position is that the Church can intend to tell you something and be wrong about that. If the pope thinks he is leading us aright when he tells us that the death penalty is currently indamissible, even though, in fact, this is wrong and leading us astray, how do you know the pope wasn't intending but failing to lead us aright when he told us that the Immaculate Conception is a divine dogma, or when he told us that his definitive teaching is infallible?
Thomas: As I've told you already, the Church and the pope cannot be wrong when they are teaching definitively; they can only be wrong when they are teaching non-definitively.
Frank: I know you've told me that, but I don't see what basis you have to think it is true. Perhaps the Church has taught this distinction, but if the Church can be wrong, how do you know she isn't wrong in her teaching regarding this distinction? How do you know the Church wasn't wrong when she defined that definitive teaching is infallible? Maybe the Church thinks that is true, but maybe she is wrong. If she can be wrong about other things, why not that? You've admitted that the Church might think and teach one thing while actually a contrary thing is true. So how do you know that isn't happening when the Church teaches that non-definitive teaching is fallible and definitive teaching is infallible?
Thomas: Well, we have to trust the Church in that matter, because otherwise Catholic epistemology collapses. We will have to be Protestants or something like that, because we will no longer be able to trust the teachings of the Church!
Frank: Yes, I agree that in order for Catholic as opposed to Protestant epistemology to be true, we must be able to trust the Church. The teaching of the Church must be reliable. That is precisely why I find your position problematic. You seem to want to have your cake and eat it too, as they say. You want to say the Church is trustworthy to lead us into truth (thus avoiding Protestantism), but then you want to turn around and say the Church is not always but only sometimes trustworthy. But once you've said that, how are you going to determine when the Church is trustworthy and when she isn't? If your only basis to determine this is reliance on Church teaching to tell you where to draw that line, well, you've undermined that basis by claiming that the Church is sometimes untrustworthy. Consider what would happen if we said the same thing about the Bible. "The Bible is trustworthy sometimes, but not other times." OK, so how do we know when it's trustworthy and when it's not? "The Bible will tell us." But the Bible isn't always trustworthy! So how do we know it's trustworthy when it tells us when it's trustworthy and when it's not? Our only rational basis for relying on the teaching of the Bible must be that we have reason to believe the Bible is generally trustworthy (not just sometimes trustworthy). Similarly, the only way we can rely confidently on the teaching of the Church is if the Church is generally (not just sometimes) reliable. She may not always intend to teach something definitively, but we can be sure that if she intends to teach us something as true, it is true. She can never lead us to think something is true that isn't.
Thomas: But you admit that the Church sometimes teaches non-definitively. Doesn't that mean she can err sometimes? How is your position different from mine?
Frank: My position (which I believe to be the Church's position as well) is that the Church is always trustworthy in all she teaches. She can never lead us into falsehood by her teaching. Therefore, when she says she is teaching something definitively, we can be sure that that teaching is definitively true. When she says she is teaching something as true but non-definitive, we can be sure that that teaching is non-definitively true. If she tells us that there is an 80% probability that Position X is the case, we can be sure that there is an 80% probability that Position X is the case. The Church cannot intend to teach something to us, and that thing she intends to teach be wrong. In the case of the death penalty, Pope Francis has taught the Church that, given the state of things in the world today, the death penalty is something we should work to avoid. How am I to respond to this? I am to believe that, given the state of things in the world today, the death penalty is something we should work to avoid. If I were to say to Pope Francis, "I know you think that is true, and you want me to believe it, but I think you're wrong, and I refuse to accept what you are telling me to believe!", then how could I be sure that this was not also the appropriate response to Pope Pius IX when he taught the Church in Ineffablis Deus that the Immaculate Conception is a doctrine revealed by God? "I know you think this doctrine was certainly revealed by God, Pope Pius IX, and I know you intend to teach us this as definitively true and you want us to believe it, but I think you're wrong!" The only basis we can have to trust the Church to draw the line correctly between non-definitive and definitive teaching, in fact the only basis upon which we can be sure of anything she teaches us (apart from our independently confirming various propositions by other means, which is what Protestants think we have to do with everything the Church teaches before we can believe it), is the conviction that the Church is inherently reliable, that whenever she teaches something she can be relied upon to be getting it right. Therefore, it follows from Catholic epistemology that we can never fail to give the assent of mind and will to any teaching of the Church, and we can never dissent from what she commands us to believe.
Published on the feast of St. Therese of Lisieux