On what occasions can we use these terms and are they perfect synonym for each other to use interchangeably? Can we say to someone who has lost a friend "our commiseration to ..."?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
In this particular case, no, they're not the same thing.
'To commiserate' means you share their grief (a noun form is rare); 'condolences' (the verb form is rare) means you feel bad for them.
Another justification (if that isn't enough), you just don't say 'we give our commiseration to you'. What is normally said is that you give or offer your condolences.
In general, outside of mathematics (and other technical stipulated vocabularies), there are no 'perfect' or exact synonyms. Different words will have different contexts/nuances/feelings and should be used where they are appropriate and not used where not. The differences may be subtle and not specified in a dictionary, but they are there nonetheless.