In most cases, a preposition should be placed before its object (I was speaking to him). However, there are a number of cases, many of which you have outlined in your examples, where it would be awkward to phrase the sentence to keep with this "rule." These cases include the following:
- questions beginning with who, what, where, when, why, and how (Where are you from? Who are you talking to? Where should you start from?)
- passive voice (The child had not been picked up. He was being spoken to.)
- with infinitives (He wanted to come with. She couldn't go around it; she had to go over)
- and with relative clauses (He liked the dog that she brought with. I know the child (that) he is talking to)
In most, if not all of the above examples, any attempt to put the preposition in front of its object would either sound obnoxiously formal, or would be improper grammar.
In your examples, "where are you from?" is better than "from where are you?" (which sounds overly formal). "To whom are you talking?" is much more formal than "Who are you talking to?" although both are correct. Same with "he's the person I was speaking to."