We are not to judge those in the world nor are we to stop talking with them. We must talk with them in order to share the Gospel.
But we are to judge those who claim to be a believer. If they are committing sexual sin, drunkards, even gossiping we are not to have anything to do with them if they do not repent. We are to first go to them and show them the error of their ways in love, but, if they refuse correction the we are to part company.
Many people will throw out one particular scripture and that is, “judge not lest ye be judged”.
If you are sinning willfully and are practicing sin then you have no grounds to go to another and talk about the speck in their eye when you have plank in your own eye. We are to judge righteously though and always in the Spirit of love and gentleness.
5:9 I wrote unto you in an epistle not to company with fornicators: 10Yet not altogether with the fornicators of this world, or with the covetous, or extortioners, or with idolaters; for then must ye needs go out of the world. 11But now I have written unto you not to keep company, if any man that is called a brother be a fornicator, or covetous, or an idolater, or a railer, or a drunkard, or an extortioner; with such an one no not to eat. 12For what have I to do to judge them also that are without? do not ye judge them that are within? 13But them that are without God judgeth. Therefore put away from among yourselves that wicked person.
World English Bible
5:9 I wrote to you in my letter to have no company with sexual sinners; 10yet not at all meaning with the sexual sinners of this world, or with the covetous and extortioners, or with idolaters; for then you would have to leave the world. 11But as it is, I wrote to you not to associate with anyone who is called a brother who is a sexual sinner, or covetous, or an idolater, or a slanderer, or a drunkard, or an extortioner. Don’t even eat with such a person. 12For what have I to do with also judging those who are outside? Don’t you judge those who are within? 13But those who are outside, God judges. “Put away the wicked man from among yourselves.”