Controlling which address my outgoing mail is seen to be from
There is a preference you can set so that composing a new message defaults to a specific mailbox rather than the currently selected mailbox. 



Replies go from the account to which the message was addressed. I'm not sure how it breaks a tie if both of your addresses are included or copied, but you can always override the "from" account by clicking on your name / email under the subject field.

In the message composition window, there's a pulldown above the message body, on the right, to select which email address you're sending from. The default for this depends on which mailbox you have selected in the main Messages window. It sounds like you're doing this.

If you're sure the above is being done for sure, then it's possible some gmail filters or tagging is getting in the way and making it look as though the reply lands in the inbox for one when really it's in another.

I would check the webmail and see if the issue is also seen there. If it is, then you're likely not sending from the right account, even if you think you are.