Actually, it depends on the email client.
You can try by parsing Message-ID
header of the inbount mail and adding it to In-Reply-To
and References
headers of the outbout (your reply) mail.
There are other headers you could use, see Sending Mail with Headers section.