This is the man who/whom i was talking to.
Which should be used in above example and why? Please help me out.
You might find that in everyday English the difference between "who" and "whom" in various contexts has disappeared and speakers prefer "who" over "whom". However, in tests and formal (purely grammatical) English the difference is this (Tips and Tricks):
In your context, "I" is acting upon "this man" who is the object of the verb "to talk". Thus we get that we need to use "whom":