Being in a state of grace means having sanctifying grace in our souls, which is necessary for salvation. We receive sanctifying grace through baptism, however, subsequent mortal sin deprives our souls of this grace and we generally must receive absolution through the Sacrament of Reconciliation to return to the state of grace.
Since mortal sin requires full knowledge (Catechism, 1859) we cannot commit mortal sin without knowing it. So, the answer to your question is yes, we can be certain that we are in a state of grace – after baptism but prior to committing mortal sin and subsequently through recourse to the Sacrament of Reconciliation.
The Church recognizes that we can know we are in a state of grace. For example, the Church requires that we be in the state of grace to receive communion: “A person who is conscious of grave sin is not to… receive the body of the Lord without previous sacramental confession…” (Canon Law, 916). The same applies to the Sacrament of Confirmation: “To receive Confirmation one must be in a state of grace” (Catechism, 1310).