AW Pink on when you are OBLIGATED to leave a church:
If any [pastor] usurps that office [established by Christ Himself], and under cloak thereof do teach or enjoin things contrary to what Christ has instituted, then no obedience unto them is required by this command. But it is just at this point that most difficulty is experienced today. For many years past large numbers of professing Christians have been demanding that the religious leaders should speak unto them “smooth things”, yea, prophesy unto them “deceits”, declining to listen unto what condemned their carnal and worldly lives and refusing to heed the holy requirements of God. In consequence, He has suffered their descendants to reap the evil sowings of their fathers, by largely withholding “pastors after His own heart”, and allowing thousands of unregenerate men to occupy the modern pulpit. Instead of “obeying” and “submitting” to them, God requires His people to turn away from and have nothing to do with them. –AW Pink, Exposition of Hebrews
From Robert Reymond’s – New Systematic Theology Of The Christian Faith:
Separation from one’s local church or denomination is appropriate if it will not discipline heretics (2 Cor. 6:14-18). If a church rejects discipline for theological errors that subvert the foundation of the gospel and becomes theologically pluralistic in practice (even though it may retain an orthodox confession by which it promises to be guided), that church has become “heretical” in that it no longer stands under the authority of God, and the orthodox are compelled to separate from it to bear witness to the marks of the church.