Before answering this question, I want to say, be sure of what you believe. Go to Gods word and be sure that it matches up with what you think you believe.
Acts 17:11 These were more noble than those in Thessalonica, in that they received the word with all readiness of mind, and searched the scriptures daily, whether those things were so.
We're to be like the Bereans, and always compare what we believe with the word of God, and similarly what others teach us with the word of God.
If we were all like this, then it would be much harder for those who teach error to lead people astray.
God's word should lead our belief, we shouldn't believe something that contradicts it.
I also want to differentiate between a few different groups here. First, what to do with someone who claims to be a believer but is openly contradicting what the word of God says. Secondly what about someone who believes something different, but they can still reconcile their beliefs to the bible, and the difference isn't something that is breaking Gods word. Thirdly those who are genuine believers, but in churches that teach error but haven't seen it yet.
2 John 1:10 If there come any unto you, and bring not this doctrine, receive him not into your house, neither bid him God speed: 11 For he that biddeth him God speed is partaker of his evil deeds.
There are some who bring teaching for example that Jesus Christ is not fully God.
This is something that is against what scripture teaches, and we're told not to bless them, or wish their work well.
We're not to receive them into our house, so we're not to have special friendship or fellowship with them.
We're not to partake in any way with their evil deeds.
Galatians 1:8 But though we, or an angel from heaven, preach any other gospel unto you than that which we have preached unto you, let him be accursed. 9 As we said before, so say I now again, if any man preach any other gospel unto you than that ye have received, let him be accursed.
We're to see them as being accursed. They will be under judgement for their sin.
Maybe we do have time where we interact with them about spiritual things, but when we do, it would be to point out their error and with the aim that they would see that what they believe is wrong, and not found in Gods word.
Again, these are those who are leading and preaching and teaching error.
It is such a terrible thing, as they will lead many astray, and ultimately to the point that Christ will say, depart from me, I never knew you.
James 5:9 Brethren, if any of you do err from the truth, and one convert him; 20 Let him know, that he which converteth the sinner from the error of his way shall save a soul from death, and shall hide a multitude of sins.
Here James is talking to brethren, or believers. He ays that if one of you believers go into errors, then there is a chance for one to win them back over.
Try if you can to win that person back.
This isn't about points scoring, or trying to win an intellectual argument. It's about sharing the word of God with that person, and letting that speak to the person.
A genuine believer will always listen to the word of God, and this is why it's so key that we're persuaded of what we believe by the word of God.
So try to win believers who are in error, but also reflect regularly on yourself and check "am I obeying and following the word of God".
So an example could be a genuine presbyterian pastor.
They believe in all the major doctrines that the bible teaches. They have a right view of God, and of Christ, and his work. They have a right view of salvation, and of man. But they believe that the bible calls us to baptise children, and for them to become part of church membership. They would still say these children need to come to the Lord and be born again.
Well, we've had pastors who have held these views come and preach in our church.
We hold to a position that children shouldn't be baptised, and that the church should be only made up of genuine believers, not their children too.
We may still be able to have fellowship and friendship with these believers.
We would try to share with them the reason why we believe that Gods word teaches something different to what they believe, but there is scope for some difference in belief.
So hopefully that helps a little.
If someone is in major error, and teaching others, and leading them astray, then you cant have close fellowship with them. It's highly likely they aren't a believer.
Try to win those who are genuine believers in churches that teach error.
And sometimes there can be differences in belief, but the other person can be completely genuine, just we differ in an area that isn't foundational.
Finally, don't assume that because someone calls themselves a christian that they are.
Always be trying to win others over, and remember your testimony in front of them. It maybe the only gospel they see for themselves in the time you spend with them.