Then he treats of the glory the saints merit by an ignominious death: ought not Christ to have suffered these things and so to enter into his glory (Luke 24:26); hence he says, if we suffer, i.e., patiently, our afflictions and reproaches, we shall also reign with him, i.e., we shall enter the kingdom along with him: blessed are they that suffer persecution for justice's sake, for theirs is the kingdom of heaven (Matt 5:10).
If we deny him, he will also deny us: he shows what will follow as punishment. But there are two ways in which a person can sin against faith: first, by denying it openly...; second, by rejecting it inwardly.
In regard to the first he says, if we deny, namely, before others, he will deny us in the judgment: amen, I say to you, I know you not (Matt 25:12). To deny is not to know them to be members of his flock.
Source: Commentary on 2 Timothy