I have Terraria under account A on my Android mobile device. How can I play it under account B that I also own?
This is impossible if you're using two different Google Accounts. If they are both using the same Google Account then search "Terraria" in the Google Play Store, and Terraria should appear as "Install", instead of "Buy" because you already bought it on that Google Account. If you are using another Google Account on your second device then you will have to buy it again. If that's the case then I recommend you add "Account A" to your device as well, as you can have more then one Google Account on one device. (Make sure you select that one when you enter the Play Store! - You can switch it back when you're done!)
In a Nutshell: Sign into/Add "Account A" to your second device!