Is it correct to say "What was your name?"?
The question is in the past tense because the person forgot the other person's name. Notice that he actually wrote "Sorry, what was your name again?". It means "You've already told me your name, but I can't remember what it is. Can you repeat?" and not that the name may have changed. If the person used the present tense (i.e. "What is your name?"), it would not have been clear that he knew that he had already asked that before.
Idiomatically, it's quite common for people to ask "What was your name?" even in contexts where both they and you know perfectly well that you haven't already given your name (and thus that they can't possibly have "forgotten" it).
Sometimes the past tense can be "explained" by saying the speaker isn't sure whether the name has already been given. Other times we might suppose if the speaker is looking for a record/document in a filing system, they're thinking in terms of your name when it was recorded (with no particular implication that it might have changed since).
But in practice the usage is sufficiently widespread, and those above possibilities so "precise", that it's unrealistic to suppose all native speakers consider carefully whether the past tense can be justified in any specific context. Some people use it, that's all.
I notice comments suggesting that because superficially the past tense may seem illogical, this somehow leads to the idea that it should be avoided in formal contexts. This I think is completely contrary to actual usage, wherein such use of the past tense is generally more formal.
My reason for saying that is that as a general principle, formal modes of address tend to use many techniques to "distance" the speaker from the current context (using one instead of I, conditional "What would you like?" rather than "What do you want?", etc.).
To my ear, "What was your name?" is in fact "formal" register. Consider a salesman saying...
"I see you're looking at our new range of [product], sir. Did you have anything particular in mind?"
"Did you want to pay by cash or by cheque?"
"Was that all, sir?"
"Will that be all, sir?"
Note particularly those last two. There aren't many contexts where it makes any difference whether the salesman uses past or future tense there - all that matters is that avoiding present tense has the effect of imposing "distance", so it's more associated with formal registers.