Thoughts like this are designed by the devil to try to draw you away from salvation. The devil is just attacking you in your thoughts. You need to ignore these thoughts when they come, or fight back at them with the word of God.
You can not loose your salvation easily. The bible tells us that even if we sin we have a advocate with the father Jesus, who speaks in our defence.
1Jn 2:1-2 My little children, these things write I unto you, that ye sin not. And if any man sin, we have an advocate with the Father, Jesus Christ the righteous: And he is the propitiation for our sins: and not for ours only, but also for the sins of the whole world.
And to understand the cross it covers our whole life time of failings, and sins.
Heb 9:27-28 And as it is appointed unto men once to die, but after this the judgment: So Christ was once offered to bear the sins of many;
Any time in your life where you seek to turn to God, He will be there for you.