Background Points
First, Paul is not writing an exact accounting of every instance of Christ being seen in 1 Cor 15:5-8. He does run through an ordered list of instances, which are leading to his point of his own late encounter (v.8).
Second, Paul is writing Corinthians after the selection of Matthias. So at the time of his writing, Matthias, chosen to take Judas Iscariot's place (Act 1:20), had become part of "the twelve" (Act 1:26). Recall that one of the requirements for Matthias joining the eleven was that he was a witness to the resurrected Jesus (Act 1:21-22).
Third, "the twelve" became a title of the core group itself, because of its usage in the Gospels (here is one discussion on it).
A Couple of Possible Solutions
So Paul's reference to "the twelve" can be logically reconciled at least two ways using the above background points:
The reference to "the twelve" was intended to include Matthias. If so, Paul is using "the twelve" in reference to the "current twelve," and his statement in 1 Cor 15:5 is saying that all the current twelve saw Jesus before the 500 brethren at once did (1 Cor 15:6). This may or may not have been at the same time as "the eleven," but the reference to Jesus showing himself to "the disciples" (John 20:19) excluded Thomas initially (John 20:24), but also is generic enough to include Matthias, who was a disciple (Act 1:15). The eleven in total actually saw him eight days later when Thomas was included (John 20:26-27; this shows that Paul is not giving an exact and total ordering of appearances in 1 Cor 15), which also was a time when "the disciples" were gathered (John 20:26), and so Matthias may have been there then.
The reference to "the twelve" was intended to exclude Matthias, being used as a title for the eleven (probably used in synecdoche)." The title "the twelve" referred to the core group, which was only eleven at the time, but the group is known as "the twelve," and so Paul could be using the title as the reference to the core group. Related to this, the title could figuratively be referring at that point in time to the partial set of the group (the eleven) by the title, using synecdoche of "the whole for the part."