Use a separate SSH key and host alias for each account, then set the commit author for each repository. This guide uses personal GitHub and work Bitbucket accounts; the same approach supports two accounts on the same provider.
Commands target Linux with Git, OpenSSH, and Bash or Zsh installed. Replace the example names, emails, account names, and repository paths with your own values. Edit configuration files by merging the examples into their existing contents.