Question: "When, why, and how does the Lord God discipline us when we sin?"
Answer: The Lord's discipline is an often-ignored fact of life for believers. We often complain about our circumstances without realizing that they are the consequences of our own sin and are a part of the Lord's loving and gracious discipline for that sin. This self-centered ignorance can contribute to the formation of habitual sin in a believer's life, incurring even greater discipline.
Discipline is not to be confused with cold-hearted punishment. The Lord's discipline is a response of His love for us and His desire for each of us to be holy. “My son, do not despise the LORD’s discipline and do not resent his rebuke, because the LORD disciplines those he loves, as a father the son he delights in” (Proverbs 3:11-12; see also Hebrews 12:5-11). God will use testing, trials, and various predicaments to bring us back to Himself in repentance. The result of His discipline is a stronger faith and a renewed relationship with God (James 1:2-4), not to mention destroying the hold that particular sin had over us.
The Lord's discipline works for our own good, that He might be glorified with our lives. He wants us to exhibit lives of holiness, lives that reflect the new nature that God has given us: “As obedient children, do not conform to the evil desires you had when you lived in ignorance. But just as he who called you is holy, so be holy in all you do; for it is written: ‘Be holy, because I am holy’” (1 Peter 1:15-16).