Thirdly, he settles a doubt. For some one might conclude that unbelievers are better for not being condemned for the above mentioned sins. But he rejects this when he says that it is not his business to judge those that are without, for God judges those outside, namely, unbelievers, because as Gregory says in Morals, unbelievers will be condemned without discussion and investigation. This is in line with Jn (3:18): "He that does not believe has already been judged," i.e., has within himself an obvious cause for condemnation.
Then when he says, Drive out the wicked one, he draws the main concl...usion saying: Since my command that you not keep company with fornicators must be understood as referring to believers and not to those who are outside, then drive out the wicked one, i.e., this man, from among you, i.e., expel him from your company: "You shall purge the evil from the midst of you" (Dt 13:5).
These words of the Apostle do not mean that we are forbidden to associate with unbelievers who have never received the faith for their punishment. Yet the weak are cautioned to avoid them, lest they be drawn away. But those strong in the faith can lawfully associate with them and try to convert them, as it says below (10:27): "If an unbeliever invites you to dinner and you are disposed to go, eat whatever is set before you." But unbelievers who once were believers, or received the sacrament of faith, as heretics or apostates from the faith, are excluded from all contact with believers. This is a punishment for them, as it is for other sinners still subject to the power of the Church.
Source: Commentary on 1 Corinthians