A couple of months ago I made a PR to a private org repo (private as in, public users have to request access in order to view it, technically private but not really). It didn't get accepted for a long time, so some time after this I decided to change my GitHub username. Recently, to my surprise however, the PR got accepted and merged. However, it now lists my old username as the author in the PR merge commit and does not link to my profile (the PR itself however, that is linked in the commit title, still links to my profile).
Will the commit change link to my profile again if I change my username back to my old one (I have never changed my GitHub email by the way)? If not, is there a way to fix this (if I have no control over this repo whatsoever)?
Regarding changing the author of a commit. Commits aren't directly associated with your GitHub account.
Commits have a committer and author associated with them. They are set by you (or rather by Git) on your machine before pushing remotely.
You can literally commit with any email and any name, even one from another user and GitHub will accept it, and it can be merged looking like it was made by someone else.
There's basically nothing you can do, the only way would be to overwrite the Git history of the repository, but most maintainers wouldn't be willing to do that since it can be messy.
If it's a public project or shared branch, it's even less likely that'd be willing to do that for you.
You'll just have to accept that that commit has your old name/email.
TL;DR: The committer and author are stored in the commit. When you do git push …
you only need to authenticate to push via your GitHub account, but that has nothing to do with the details stored in the commit.
As for the merge commit message, you can technically fix the link in your merge commit by changing your username back to the old one. However, I wouldn't say it's worth doing.
The commit is still attributed to you, it's just the merge commit message that no longer resolves to your profile because it's simply a plaintext field. In commit messages, pull request descriptions, and comments, GitHub links @usernames to the respective profile. It's the same as how other platforms like Twitter do it. Just because someone mentioned you before doesn't mean you need to hold on to that username for life now!