It's nice to talk to you.

When do we use “It’s nice to talk to you?” Is it just a way of saying that the hearer is nice to talk to or can it also be used when we have just finished talking with someone? I mean, what does it mean in terms of time aspect?

Thanks.

“It’s nice talking to you” or “it’s nice to talk to you”: the simple present tense (“is”) would be used here to say that you enjoy talking to someone in general, or at all times. You would probably say this in the middle of conversation, not at the end (though perhaps that wouldn’t be impossible). It is as though suddenly the thought occurred to you “hey, this person is a nice guy to talk to”, an observation. It is usually an expression of affection and it is not quite common in business or casual talks.

“It was nice talking to you” is a very common way of ending a conversation: it means that the conversation has just ended and that you enjoyed it or that it was good in any sense. Usually it is little more than a polite way of saying “well, I think we have talked about all we needed to for now, I must be going”.
It is somewhat informal; you might say “thank you (very much) for your time” in more formal, business-like conversations, or “it has been a (great) pleasure” in formal but non-business-like conversations.