Matthew 10:32-33
32 Whosoever therefore shall confess me before men, him will I confess also before my Father which is in heaven.
33 But whosoever shall deny me before men, him will I also deny before my Father which is in heaven.
Luke 12:8-9
8 Also I say unto you, Whosoever shall confess me before men, him shall the Son of man also confess before the angels of God:
9 But he that denieth me before men shall be denied before the angels of God.
These verses have been used to say that public confession before men is required to get to Heaven. Public confession can then be defined as living a life of obedience to Christ before men, and therefore these verses are also used to teach works Salvation.
As with any and all additions to Salvation beyond simple faith, this is nonsense, and I will demonstrate exactly why.
The clear testimony of Scripture is that whoever trusts Jesus Christ to save them has Everlasting Life:
John 6:47
47 Verily, verily, I say unto you, He that believeth on me hath everlasting life.
So is believing something the same thing as confessing that you believe it before men, either by word or by actions? Not even close. Will your mouth start vocalizing the fact that you believe something the moment you believe it? Of course not.
For example, I believe that I should exercise and eat healthy. Do I always do so? No. Do I tell others that I believe that? Apart from now, no. To deny that belief and actions can be disconnected is to deny that someone can be a hypocrite, which is insane because we all are in many aspects of our lives.
The Bible, then, can only teach one of the following:
Both cannot be true, and if the second option is true, then the clear statement in John 6:47 becomes an out-and-out lie, as it would be possible to believe on Jesus and not have Everlasting Life.
The Bible even gives us an example where people are described as having believed on Jesus Christ (with no indication at all that the belief was somehow disingenuous), and yet didn't confess Him because of fear:
John 12:42
42 Nevertheless among the chief rulers also many believed on him; but because of the Pharisees they did not confess him, lest they should be put out of the synagogue:
Similarly, Peter denied that he knew Jesus because he was afraid, yet all the while he believed that Jesus was the Christ. He was simply being a hypocrite (and a liar).
Paul generally describes what we can call a hypocrite in Romans 4, who has no works. Yet his faith is regarded as genuine because it is nonetheless accounted to him for righteousness:
Romans 4:5
5 But to him that worketh not, but believeth on him that justifieth the ungodly, his faith is counted for righteousness.
Confession and belief are not synonymous, and confession that you believe something is not a prerequisite for genuinely believing something. The same goes for doing actions in accordance with your beliefs, which can be seen as "confessing" or bearing witness in a sense to the fact that you believe something.
Factors such as temptation and the difficulty of living consistent with that belief can make hypocrisy very hard to avoid, or in our case as Christians, impossible to avoid (Matthew 5:48)!
These are the same reasons why another passage that people use to teach confession or prayer for eternal Salvation, Romans 10:9-13, cannot be teaching such a thing. I cover that passage in-depth in an article titled You Do Not Have to Pray or Confess to be Saved, so I won't rehash all that here, but I did want to touch on it because it's related to these passages in Matthew and Luke.
Since confession of our faith in Christ, whether in word or deed, is not automatic, our doing so depends on our own efforts - our own works. If this were then a requirement to be eternally saved, could you really say that Salvation is not of works (Ephesians 2:8-9, Romans 11:6, Titus 3:5)? Absolutely not.
Furthermore, we know that at no future point can a believer come into eternal condemnation:
John 5:24
24 Verily, verily, I say unto you, He that heareth my word, and believeth on him that sent me, hath everlasting life, and shall not come into condemnation; but is passed from death unto life.
Therefore the denial that Christ makes before God and the angels that is spoken of in Matthew 10:32-33 and Luke 12:8-9 is not referring to being denied entrance into Heaven. It's referring to an aspect of the Judgement Seat of Christ.
This judgement is for believers only, and it determines to what extent they will inherit the Kingdom of God, their level of rewards, and authority in the Kingdom:
2 Corinthians 5:10
10 For we must all appear before the judgment seat of Christ; that every one may receive the things done in his body, according to that he hath done, whether it be good or bad.
Christ will then consider your life and give or deny you rewards based on how you lived:
1 Corinthians 3:13-15
13 Every man's work shall be made manifest: for the day shall declare it, because it shall be revealed by fire; and the fire shall try every man's work of what sort it is.
14 If any man's work abide which he hath built thereupon, he shall receive a reward.
15 If any man's work shall be burned, he shall suffer loss: but he himself shall be saved; yet so as by fire.
It's here that Jesus will confess that you have confessed Him before men (in deed and in word), or deny that you have done so. That will be a factor in the judgement and as to what you receive for your labor on earth.
But note that even if a man is denied any reward - if all that he has done is burned up - he himself is still saved. That's because once a believer is saved, they are always saved, even if they waste their lives walking in the flesh and committing lots of sins.
When we interpret passages in light of the clear statement of Scripture such as John 6:47, Ephesians 2:8-9, and John 3:36, we will always find that any verse appearing to teach something in addition to faith as necessary for Salvation cannot possibly be doing so.
These verses are no exception. While we, as believers, will never be denied Eternal Life, we will be denied rewards and authority in Christ's Kingdom if we live pointless, wasteful lives of sin here on earth.
That's why obedience is so important - not because it determines your eternal destiny - but because it determines the eternal destiny of potentially thousands of others that you failed to reach by disobeying. There's still a lot at stake for yourself and others that makes obedience extremely important, but your Salvation is not part of that.