while you are moving content to B.com, disallow Googlebot from accessing it, using robots.txt When you are done with the movement, allow Googlebot to access B.com Then use .htaccess or a PHP script to put a HTTP 301 (moved permantently) header in A.com, redirecting to B.com
You need to properly 301 redirect all the old URLs to the new URLs via the .htaccess file, do some research on this to make sure you do it properly and not lose any SERPs or Pagerank.
Yeah, 301 redirect is correct way to do this without hurting your site's rank. And do this move from a.com to b.com quickly, as if your site is down for some time, you can lose your search results ranking.