An ongoing study by IIT Kharagpur shows that civilization may have existed in Varanasi as long as 4500 BC.
My question is inspired by this study. What are the references available to Varanasi or Benaras in Ramayana and Mahabharata?
I'm not sure about Ramayana, but Varanasi is certainly mentioned in Vedas and Mahabharata. I discuss about Varanasi in Vedas in my answer here. The Mahabharata also mentions the name Varanasi and Kasi many times. In the city Varanasi also the place where Lord Avimukta is present (Visweshar Linga) is the most sacred. The Mahabharata in the Vana parva Tirtha Yatra section also talks about the glory of Varanasi and Lord Avimukta there. It's in this chapter of Mahabharata:
ततो वाराणसीं गत्वा अर्चयित्वा वृषभध्वजम् ।
कपिलाहृदे नरः स्नत्वा राजसूयमवाप्नुयात् ।।
अविमुक्तं समासाद्य तीर्थसेवी कुरुद्वह ।
दर्शनाद् देवदेवस्य मुच्यते ब्रह्महत्यया ।।
प्राणानुत्सृज्य तत्रैव मोक्षं प्राप्नोती मानवः ।।
Proceeding next to Varanasi, and worshipping the god having the bull for his mark, after a bath in the Kapilahrada, one obtaineth the merit of the Rajasuya sacrifice. Repairing then, O perpetuator of the Kuru race, to the tirtha called Avimukta, and beholding there the god of gods, the pilgrim, from such sight alone, is immediately cleansed of even the sin of slaying a Brahmana. By renouncing one's life there, one obtaineth Moksha.
Thus the most glory of Lord Avimukta in Varanasi is that anyone who dies there attains moksha. As the above Mahabharata sloka states " प्राणानुत्सृज्य तत्रैव मोक्षं प्राप्नोती मानवः ।।" ie. "One who gives away Prana there (Prãnutsrijya tatraiva) is sure to obtain Moksha (Moksham Prãpnoti Mãnava)
As a Sidenote, Lord in Varanasi is called Lord Avimukta because Varanasi is never forsaken by Lord Shiva. And Avimukta literally means which is never forsaken. As described in answer here Kashi is not destroyed by Lord Shiva even after completion of Kalpa:
ब्रह्मणश्च दिने सा हि न विनश्यति निश्चितम्।
तदा शिवस्त्रिशूलेन दधाति मुनयश्च ताम्।। २३ ।।
Even after the completion of a divine day of Brahmā, the city of Kāšî does not get destroyed. O Sages, at that point of time, Siva holds it over the tip of his trident.
पुनश्च ब्रह्मणा सृष्टौ कृतायां स्थाप्यते द्विजाः ।
कर्मणां कर्षणाचैव काशीति परिपठ्यते॥ २४॥
O Brähmanas, then Brahmā again recreates the universe, then he again establishes Kāśī. Because of the bondages of the karmas and their attraction thereto, it is called Kāši.
Yes, Kashi (Varanasi) finds mention in both the itihasas - the Ramayana and the Mahabharata.
तथा काशीपतिं स्निग्धं सततं प्रियवादिनम् । सद् वृत्तं देवसंकाशं स्वयमेवानयस्व ह ॥ १-१३-२३ ॥
"Thus that King of Kaashi who is always a friendly, affectionate, and a cordial one, indeed he shall be invited by you personally. [1-13-23]
यावदावर्त ते चक्रं तावती मे वसुन्धरा ॥ २-१०-३६ ॥ प्राचीनाः सिन्धुसौवीराः सौराष्ट्रा दक्षिणापथाः । वङ्गाङ्गमगधा मत्स्याः समृद्धाः काशिकोसलाः ॥ २-१०-३७ ॥
My jurisdiction over this earth stretches out as much to the extent as to the extent a chariot wheel revolves. Eastern countries, Sindhu, Sauvira, and Saurashtra countries, as well as countries in the south, Vanga, Anga, Magadha, and Matsya countries, Kasi and Kausala countries are all full of riches.
विसर्जयामास तदा कौसल्यानन्दवर्धनः । राघवेणाभ्यनुज्ञातः काशीशो ऽप्यकुतोभयः । वाराणसीं ययौ तूर्णं राघवेण विसर्जितः ॥ ७.३८.२० ॥
विसृज्य तं काशिपतिं त्रिशतं पृथिवीपतीन् । प्रहसन्राघवो वाक्यमुवाच मधुराक्षरम् ॥ ७.३८.२१ ॥
Having bade farewell to his maternal uncle, Rama embraced his friend, Pratardana, the King of Kashi, and addressed him in these words:—
“You have proved your friendship and devotion to the full, O Prince, as witnessed by the campaign undertaken with Bharata. Now return this day to the enchanting City of Benares of which you are the support and which is surrounded by great walls and magnificent gateways.
Besides these, there are numerous other references too.
A very famous reference to Kashi in the Mahabharata, in my view, involves the three princesses of Kashi - Amba, Ambika & Ambalika, the two of whom marry Satyavati's son Vichitravirya, and the other, Amba, who is re-born as Shikandhi.
उक्त्वा भीष्मवधायेति प्रविवेश हुताशनम् ।
ज्येष्ठा काशिसुता राजन्यमुनामभितो नदीम् ॥ १८ ॥
Upon this, that faultless maiden of the fairest complexion, the eldest daughter of the king of Kashi, procuring wood from that forest in the very sight of those great Rishis, made a large funeral pyre on the banks of the Yamuna, and having set fire to it herself, entered that blazing fire, O great king, with a heart burning with wrath, and uttering, O king, the words,—(I do so) for Bhishma’s destruction!'"