I am working for A in India and B is filing H-1B petition. How to transfer it to A before stamping before Oct 1?

I am currently working for company A in India. A consulting company B has agreed to file H-1B on my behalf. If my petition is approved, can I transfer it to company A before October 1st? What are the risks involved and what is the procedure to do this transfer?

Yes, A can file cap-exempt petition for you using B’s approved petition. Process is similar to what B is doing right now for you. The additional doc will be proof of B’s approval i.e. 797 approval notice. Usual risks related to any petition.