Provided the content for the different subdomains is on each host, all of the changes can be made at the DNS level. So you would point
www.domain.com to host1 and www2.domain.com to host2. There are also ways to keep the subdomains the same and use a form of round robin in the A records to go from one to the other.