Hypothetically, if we died right after being baptized (or, if due to extraordinary circumstances we were unable to recieve baptism, we died right after accepting Christ) we would not have to do good works to be saved. Allow me to explain a little clearer.
The Catholic Church views salvation as a covenant, not a contract. We enter this covenant through faith in (and love of) Christ, at baptism. God adopts us into His family, forgives our past sins, and sanctifies our interior selves. We are translated into a state of grace, and as long as we remain in this state, we will not fall under God's judgement. However, that is not the end of the process. Ultimately, God requires perfection. So, throughout our earthly lives, and even after they are over, God will continue sanctifying us until he conforms us to the image of Christ i.e. makes us perfect. On our part, we must cooperate in this process, which involves doing good works. So in that sense good works are necessary for salvation. This doesn't mean that we earn salvation, since the ability to do good works is itself a gift of God; it just means that it's possible to accept the gift or to reject it. If we rebel against God and refuse to cooperate with His sanctifying grace by refusing to do the good works which He prompts us to do, we can disinherit ourselves of His covenant promises. Then, we must repent and turn back to Him.