It depends on the starting date of your H1B application with company B. Should be OK if they ask you to report in on a certai date. You can take this time to notify your company A that you are leaving as a good ethic.