From ST II-II.10.7c:
I answer that, in disputing about the faith, two things must be observed: one on the part of the disputant; the other on the part of his hearers. On the part of the disputant, we must consider his intention. For if he were to dispute as though he had doubts about the faith, and did not hold the truth of faith for certain, and as though he intended to probe it with arguments, without doubt he would sin, as being doubtful of the faith and an unbeliever. On the other hand, it is praiseworthy to dispute about the faith in order to confute errors, or for practice.
On the part of the hearers we must consider whether those who hear the disputation are instructed and firm in the faith, or simple and wavering. As to those who are well instructed and firm in the faith, there can be no danger in disputing about the faith in their presence. But as to simple-minded people, we must make a distinction; because either they are provoked and molested by unbelievers, for instance, Jews or heretics, or pagans who strive to corrupt the faith in them, or else they are not subject to provocation in this matter, as in those countries where there are not unbelievers. On the first case it is necessary to dispute in public about the faith, provided there be those who are equal and adapted to the task of confuting errors; since in this way simple people are strengthened in the faith, and unbelievers are deprived of the opportunity to deceive, while if those who ought to withstand the perverters of the truth of faith were silent, this would tend to strengthen error. Hence Gregory says (Pastor. ii, 4): "Even as a thoughtless speech gives rise to error, so does an indiscreet silence leave those in error who might have been instructed." On the other hand, in the second case it is dangerous to dispute in public about the faith, in the presence of simple people, whose faith for this very reason is more firm, that they have never heard anything differing from what they believe. Hence it is not expedient for them to hear what unbelievers have to say against the faith.