A short answer to this question, is through faith in Jesus Christ who offered himself as a sacrifice for sin.
A more detailed answer:
We are sanctified or made holy, by the word of God and through the offering of the body of Jesus (John 17:17-19). How does this happen?
God’s seed or gospel takes root in us (1 Peter 1:23-25) – this happens by us eagerly reading God’s word and letting it affect our minds and our actions. We no longer serve the flesh but the living God and the blood of Jesus cleanses us from sin. (Eph 5:26; Heb 9:14)
1 John 1:7-9 shows us that even though we are cleansed from sin, we will still sin. Nevertheless we have to keep up the battle against sin and confess our sins to God and we will be forgiven:
But if we walk in the light, as he is in the light, we have fellowship with one another, and the blood of Jesus his Son cleanses us from all sin. (8) If we say we have no sin, we deceive ourselves, and the truth is not in us. (9) If we confess our sins, he is faithful and just to forgive us our sins and to cleanse us from all unrighteousness.
1 Peter 2:24
He himself bore our sins in his body on the tree, that we might die to sin and live to righteousness. By his wounds you have been healed
This death to sin is typified in our baptism, where we go down into the water which represents the grave and the death of the old man of the flesh. We rise from the water a new creature – one who lives to God. We then follow Jesus taking up our cross daily – meaning we daily crucify the lusts of the flesh the lusts of the eyes and the pride of life. Then the wounds of Jesus will heal us – we will be forgiven if we adopt this life in the spirit.
Romans 6:17-23 is a good summary of this subject:
But thanks be to God, that you who were once slaves of sin have become obedient from the heart to the standard of teaching to which you were committed, (18) and, having been set free from sin, have become slaves of righteousness. (19) I am speaking in human terms, because of your natural limitations. For just as you once presented your members as slaves to impurity and to lawlessness leading to more lawlessness, so now present your members as slaves to righteousness leading to sanctification. (20) For when you were slaves of sin, you were free in regard to righteousness. (21) But what fruit were you getting at that time from the things of which you are now ashamed? For the end of those things is death. (22) But now that you have been set free from sin and have become slaves of God, the fruit you get leads to sanctification and its end, eternal life. (23) For the wages of sin is death, but the free gift of God is eternal life in Christ Jesus our Lord.