A1. To whom were you speaking?
A2. To who were you speaking?
A3. Who were you speaking to?
B1. They asked to whom I was speaking.
B2. They asked to who I was speaking.
B3. They asked who I was speaking to.
A1 and B1 are formal English, but, as we know, one can replace 'whom' with 'who' nowadays.
I'm unsure if this replacement implies the movement of the preposition (to in the above examples) towards the end of the sentence—like in A3 and B3—, or not—like in A2 and B2? If so, is there difference under this aspect between the case in which the sentence is affirmative (B2 and B3) and the case in which the sentence is interrogative (A2 and A3)?