This answer is for Shiva Lingas and Shaiva temples.
It is allowed to touch Shiva Lingas in temples and mostly it depends on Sthala Puranas. For example, in Shiva Mahapurana Lord Shiva says by touching Agni Linga at Arunachala (Tiruvannamalai) one will become free from Samsara.
In Chapter 9, Vidyeswara Samhita of Shiva Mahapurana, Lord Shiva says: (translated by Jl Sastri)
भोगावहमिदं लिंगं भुक्तिं मुक्त्येकसाधनम् |
दर्शनस्पर्शनध्यानाज्जंतूनां जन्ममोचनम् || २०
20.The Linga confers enjoyment. It is the only means of worldly enjoyment and salvation. Viewed, touched or meditated upon, it
wards off all future births of the living beings.
अनलाचलसंकाशं यदिदं लिंगमुत्थितम् |
अरुणाचलमित्येव तदिदं
ख्यातिमेष्यति || २१
21.Since the Linga rose high resembling a mountain of fire, this shall be famous as Aruna mountain.
Similarly, Lord Shiva says those who touch Mahakala Linga at Mahisagara samgama tirtha will go to abode of Shiva. Kaumarika Khanda, Maheshwara Khanda of Skanda Purana describes Tirthas of Mahisagara Sangama in detail.
Chapter 41, Kaumarika Khanda, Maheswara Khanda of Skanda Purana says:
189-190. If the Linga is visited, touched and worshipped, those men
will go to the abode of Bhava. Thus, O Phalguna, these seven Lingas
came into existence. Those who listen to this and praise these are
excellent men. They are blessed.
At Srikalahasti, Vayu Linga is not allowed to touch even by priests, as it is believed once finger of a priest turned to gold after touching it (will update the source shortly), though there are stories of Bhakta kannappa, Spider (Sri), Snake (kala) and Elephant (hasti) worshiping the Linga.
So, in most cases it depends on Stahala Puranas for Shiva temples.