The check doesn't have to match
either name, since names are not what the IRS uses to match payments to returns. The check simply has to have the SSN (or ITIN) of at least one of the joint filers.
It's really not a hard problem.
It's actually an extremely hard problem if you try to match payments by name, since there are a lot of people with the same exact name, many of whom even live in the same state or same city. Most checks don't include an address, and even those that do don't always match the address the taxpayer gave on the return.
It sounds like you failed to include your SSN on the check, which means this problem was one of your own making. That being said, if you could provide proof that payment was timely sent and the check details (check #, account, etc.), the IRS can match the payment received and will void penalties and interest that were assessed.