I haven't really checked recently if it still behaves like following but atleast it used to.
When you start a new message conversation it will use the default number set in settings for imessage and this setting has to be set on every device.
When you reply to a message it will use the number or email that the last message was sent from or to on all devices as long as the number or email is activated for imessage in settings on the device (which it should be by default).