- "I assign a number to each person."
- "To each person, I assign a number."
Both are correct. The second one can include the comma but it is not strictly necessary. It is well understood in speech too.
There is a subtle difference in what is emphasized in each sentence. Generally, the emphasis is understood to be on the end of the sentence. You can consider the last words as having implicit stress: "I assign a number to each person" emphasizes the persons (you are likely to continue talking about them, and the numbers are of secondary importance), but "To each person, I assign a number" suggests that either the number each person has, or the action of numbering, is the important fact here.
See also Pullum's "50 Years of Stupid Grammar Advice" which quotes Elements of Style saying
Place the emphatic words of a sentence at the end. (This advice is not stupid!)