Hi.
You will need to create a new forward lookup zone on your internal DNS server for test.com. In that zone, create a Host A record for mail and point it to the internal address.
This way, every time the laptop is in the office it will resolve mail.test.com to the internal IP. If it is out of the office, it will resolve according to your external DNS settings.