Not sure if I understand the scenario right. Most of the time when you set up mailboxes for your users, they want some or a lot of secondary e-mail addresses, so they'll be able to receive mail hen senders are using them. However, they use their primary SMTP address when they send or reply to mail.
Is it so, that when the e-mail goes to B, you also want that the reply comes from B and not the primary SMTP address, which is A? So basically these are two distinct e-mail addresses that need to be kept separate? If so, give each of the two users two mailboxes. You could start with a shared mailbox, which does not require a license.. However, there are som limitations with shared mailboxes. If you run into one of them, you can easily convert them to user mailboxes and chose the cheapest license plans.
You connect both mailboxes to the same Outlook profile. The user can select from which one she or he wants to send new mails.
Add rules to a Shared Mailbox
https://support.microsoft.com/en-us/office/add-rules-to-a-shared-mailbox-b0963400-2a51-4c64-afc7-b816d737d164
P.S. There i a lot of things you can do with Exchange Transport rules (mail flow rules), which are more powerful than Outlook rules. So if we get a clearer picture of your scenario, this could be an option as well.
--please don't forget to Accept as answer if the reply is helpful--