Not sure. But the main story comes from Gokarna mahatya . Gokarna is mentioned as Shiva ksetra in Vana Parva (Ramopakhyana which is dated to 2nd BCE by scholars)
In Vana Parva(Ramopakhyana ) Gokarna is mentioned as Shiva ksetra where mahadev is worshipped.
- तमतीत्याथ गोकर्णमभ्यगच्छद्दशाननः ।
- दयितं स्थानमव्यग्रं शूलपाणेर्महात्मनः ॥
- “Having crossed beyond it, Daśānana (Rāvaṇa) approached Gokarṇa, the beloved, tranquil place of the great-souled Śūlapāṇi (Śiva).”