Salvation is by grace, but if a person commits adultery that means they don't have the grace of God.
James 4:7 - Resist the devil, and he will flee from you.
Salvation is not in our hands, but we must always be willing to do God's will. If we don't care, we will probably lose grace.
Once Grace, as in the new birth of John 3:1-10, is received and the believer puts his/her trust in Jesus Christ, this saving Grace can never be lost. If that were possible, it would make Christ a liar. For what God begins, He will bring to conclusion.
While the believer should put on Christ and live his/her life as Jesus Christ lived his, we still have the ole' sin nature in our flesh. Something Jesus did not have. Therefore, sin is still a distinct reality as the believer wars with the flesh. A believer could certainly commit adultery, just as David did in the OT and David was called by God "a man after His own heart". David went on to commit other sins than adultery. While he did repent of them and paid a heavy price because of them, his Salvation was never in doubt.
The believer today will commit sins and will need to go before the Father seeking forgiveness for them and that forgiveness will be given because of the continual washing, with the blood of Christ.
1Jn 1:7-10 but if we walk in the light, as he is in the light, we have fellowship one with another, and the blood of Jesus his Son cleanses us from all sin. If we say that we have no sin, we deceive ourselves, and the truth is not in us. If we confess our sins, he is faithful and righteous to forgive us our sins, and to cleanse us from all unrighteousness. If we say that we have not sinned, we make him a liar, and his word is not in us.