I believe that one must not only have faith but also endure to the end to be saved and that one can lose their salvation if they stray away. How does the Catholic church stand on this?
The Church teaches that “Faith is an entirely free gift that God makes to man. We can lose this priceless gift, as St. Paul indicated to St. Timothy: "Wage the good warfare, holding faith and a good conscience. By rejecting conscience, certain persons have made shipwreck of their faith” (1 Tim 1:18-19). To live, grow and persevere in the faith until the end we must nourish it with the word of God; we must beg the Lord to increase our faith; (Cf. Mk 9:24; Lk 17:5; 22:32) it must be “working through charity,” abounding in hope, and rooted in the faith of the Church.” (Gal 5:6; Rom 15:13; cf. Jas 2:14-26)
We can therefore hope in the glory of heaven promised by God to those who love him and do his will” (Cf. Rom 8:28-30; Mt. 7:21). In every circumstance, each one of us should hope, with the grace of God, to persevere "to the end” (Mt 10:22) and to obtain the joy of heaven, as God’s eternal reward for the good works accomplished with the grace of Christ. In hope, the Church prays for "all men to be saved.” (1 Tim 2:4) She longs to be united with Christ, her Bridegroom, in the glory of heaven (CCC 1821).
Those who die in God’s grace and friendship and are perfectly purified live for ever with Christ. They are like God for ever, for they “see him as he is,” face to face.” (CCC 1023)
The teaching of the Church affirms the existence of hell and its eternity. Immediately after death the souls of those who die in a state of mortal sin descend into hell, where they suffer the punishments of hell, “eternal fire.” The chief punishment of hell is eternal separation from God, in whom alone man can possess the life and happiness for which he was created and for which he longs. (CCC 1035)
When he comes at the end of time to judge the living and the dead, the glorious Christ will reveal the secret disposition of hearts and will render to each man according to his works, and according to his acceptance or refusal of grace. “ (*CCC * 682)
Assurance of Salvation