There was a mention of Punya in Rig Veda II.43.2
उद्गातेव शकुने साम गायसि बरह्मपुत्र इव सवनेषु शंससि | वर्षेव वाजी
शिशुमतीरपीत्या सर्वतो नः शकुने भद्रमा वद विश्वतो नः शकुने पुण्यमा वद
Thou like the chanter-priest chantest the Sāma, Bird; thou singest at
libations like a Brahman's son. Even as a vigorous horse when he comes
near the mare, announce to us good fortune, Bird, on every side,
proclaim in all directions happy luck, O Bird
Here, punya, is used can mean - 'good' or 'auspicious' or 'happy'.
Second Mandala of Rig Veda is the Oldest one, and hence, the meaning with which the Rishi used the word punya, in this mantra cannot be stated for sure.
In Ramayana, while lamenting Sita uses the words punya and paapa, in Sundara Kanda, indicating good or bad merit.
एषाल्पपुण्या कृपणा विनशिष्याम्यनाथवत् | समुद्रमथ्ये नौः पूर्णा
वायुवेगैरिवाहता || ५-२५-१४
"This me with small merit,wreched, like an orphan, will perish like a
ship in the middle of the ocean being hit by the speed of wind."
कीदृशं तु महापापं मया जन्मान्तरे कृतम् | येनेदं प्राप्यते दुःखं मया
घोरं सुदारुणं || ५-२५-१८
"By what this horrible and very dreadful grief is obtained by me, what
kind of great sin had been done by me in another life."
Vivekachudamani says as follows: (504 verse)
पुण्यानि पापानि निरिन्द्रयस्य निश्चेतसो निर्विकृतेः निराकृतेः | कुतो
ममाखण्डसुखानुभूतेः ब्रूते ह्यनन्वागत मित्यपि श्रुतिः ||
"How can there be for me puṇya and pāpa who am without organs,
without mind, without change and without form? How can these pertain
to me who enjoy infinite bliss? In the passage, 'not touched' etc.,
Sruti also mentions this."
Here, Sri Sankara was talking about Atma or Soul, which remains untouched with puṇya and pāpa.
From the above, we can infer that the punya and paapa in the subsequent literature to Rig Veda, were used to denote outcome of karmas done, good or bad, with the intention of getting results, as Karma done without expecting result does not give rise to any punya or paapa, but liberation - Sri Krishna says in BG.
कर्मण्येवाधिकारस्ते मा फलेषु कदाचन।
मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि।।2.47।।