You can't currently use an account to trigger a transaction from another account, and currently the account that triggers the transaction has to pay for the gas.
If A can be a contract rather than an Externally Owned Account, you can give the contract methods to allow it to be called by the Main account, causing it to send funds to B. In this case the Main account is triggering the transaction, so the gas will come from the Main account.
Alternatively, with ERC 20 tokens, it's possible to approve()
another address to spend funds on your behalf. So you could make a single call from A (for which A will have to pay gas) to approve a large sum of money, which will cover many small payments from A's account to B's. That way A only has to pay for gas once, after which gas can be paid for by Main. If you don't want to trust Main to make all these calls without restriction, you could make an intermediate contract that has to be called by Main, specifying under what circumstances it can spend funds belonging to A.