They all have different nuance. They especially cannot be interchanged because of how different religions refer to their places of worship.
A "sanctuary" can be any place where the people or things inside are not allowed to be harmed. For example: a wildlife sanctuary. It would sound very strange to my ear to say "I'm going to the sanctuary to pray"; I don't know any religion which refers to their place of worship as simply "sanctuary".
A "shrine" is typically a specific object or area devoted to honouring a specific person, people, or deity, and may or may not have religious connotations. For example, there is a structure in Melbourne, Australia which is to preserve the memory of soldiers who have fought in Australia's wars, called the Shrine of Remembrance. It is also the standard English translation of a Shinto place of worship.
A "temple" is a type of place of worship. But you wouldn't use the word "temple" interchangeably with "church", "synagogue", "mosque", nor with "place of worship" itself. Something is a "temple" if that's what the people that worship there call it.