Apart from divine revelation, one cannot be absolutely certain one is in the state of grace, though there are signs one might be.
Council of Trent session 6 on Justification, Chapter IX. "Against the vain confidence of heretics" (Denzinger 802):
But, although it is necessary to believe that sins neither are remitted, nor ever were remitted save gratuitously by the mercy of God for Christ's sake; yet is it not to be said, that sins are forgiven, or have been forgiven, to any one who boasts of his confidence and certainty of the remission of his sins, and rests on that alone; seeing that it may exist, yea does in our day exist, amongst heretics and schismatics; and with great vehemence is this vain confidence, and one alien from all godliness, preached up in opposition to the Catholic Church. But neither is this to be asserted—that they who are truly justified must needs, without any doubting whatever, settle within themselves that they are justified, and that no one is absolved from sins and justified, but he that believes for certain that he is absolved and justified; and that absolution and justification are effected by this faith alone: as though whoso has not this belief, doubts of the promises of God, and of the efficacy of the death and resurrection of Christ. For even as no pious person ought to doubt of the mercy of God, of the merit of Christ, and of the virtue and efficacy of the sacraments, even so each one, when he regards himself, and his own weakness and indisposition, may have fear and apprehension touching his own grace; seeing that no one can know with a certainty of faith, which can not be subject to error, that he has obtained the grace of God.
Trent also defined these de fide dogmas:
CANON XIII.—If any one saith, that it is necessary for every one, for the obtaining the remission of sins, that he believe for certain, and without any wavering arising from his own infirmity and indisposition, that his sins are forgiven him: let him be anathema.
CANON XVI.—If any one saith, that he will for certain, of an absolute and infallible certainty, have that great gift of perseverance unto the end,—unless he have learned this by special revelation: let him be anathema.