When Ravana was dying in the battlefield after getting hit by Lord Rama, Lord Rama sent Lakshmana to Ravana.
Ravana and Lakshmana had some conversation. What was it all about?
Lakshmana did not have a conversation with Ravana on his death bed; there was no time to have a such a conversation, since Ravana was killed as soon as he was struck by Rama's Brahmastra (which I discuss in this answer), as described in the Yuddha Kanda of the Ramayana:
Making [the Brahmastra] sacred by a special formula as per the procedure specified in scriptures, Rama who was endowed with an extraordinary strength then fixed that arrow which was the foremost among the three worlds, capable of removing the fear of Ikshwaku dynasty, taking away the glory of the enemies and bestowing joy to one's own self on his bow. While that excellent arrow was being fixed by Rama, all the beings were frightened and the earth trembled. That enraged Rama, stretching his bow well and with an attentive mind, hurled that arrow which can tear off the vitals, towards Ravana. That arrow, which was inviolable as a thunderbolt hurled by the arms of Indra and irresistible as Yama the lord of Death, fell upon Ravana's chest.
That arrow, released with great speed and which was capable of destroying the body, tore off the heart of that evil-minded Ravana. That arrow, which was capable of causing death to the body, after taking away the life of Ravana and having been anointed with blood, penetrated the earth. Smeared with blood on having killed Ravana and thereby accomplishing its mission, that arrow re-entered its own quiver (of Rama) silently. From the hands of the slain Ravana, who was being separated from his life, fell his bow with its arrows (fitted to it), at the same time coinciding indeed with his life-breath. Having lost his life, that king of demons for his part, who was endowed with terrible swiftness and invested with great splendour, fell down from the chariot to the ground, like Vritra the demon when the latter was struck down by the thunderbolt.
So the story you heard is probably from some later version, perhaps Tulasidas' Ramcharitmanas or something else.
This story appears to be from a folk version of Rāmāyaṇa, it's not part of the original Vālmīki Rāmāyaṇa.
Devdutt Pattanaik writes about this in his article This was Ravan too, but he uses a variety of sources for his article.
According to Pattanaik's article, here's the conversation that took place between Rāma, Lakṣmaṇa and Rāvaṇa:
The story goes that after firing the fatal arrow on the battlefield of Lanka, Rama told his brother, Lakshmana, "Go to Ravana quickly before he dies and request him to share whatever knowledge he can. A brute he may be, but he is also a great scholar."
The obedient Lakshmana rushed across the battlefield to Ravana's side and whispered in his ears, "Demon-king, do not let your knowledge die with you. Share it with us and wash away your sins."
Ravana responded by simply turning away. An angry Lakshmana went back to Rama, "He is as arrogant as he always was, too proud to share anything." Rama comforted his brother and asked him softly, "Where did you stand while asking Ravana for knowledge?"..."Next to his head so that I hear what he had to say clearly." Rama smiled, placed his bow on the ground and walked to where Ravana lay. Lakshmana watched in astonishment as his divine brother knelt at Ravana's feet.
With palms joined, with extreme humility, Rama said, "Lord of Lanka, you abducted my wife, a terrible crime for which I have been forced to punish you. Now, you are no more my enemy. I bow to you and request you to share your wisdom with me. Please do that for if you die without doing so, all your wisdom will be lost forever to the world."
To Lakshmana's surprise, Ravana opened his eyes and raised his arms to salute Rama, "If only I had more time as your teacher than as your enemy. Standing at my feet as a student should, unlike your rude younger brother, you are a worthy recipient of my knowledge. I have very little time so I cannot share much but let me tell you one important lesson I have learnt in my life.
Things that are bad for you seduce you easily; you run towards them impatiently.
But things that are actually good for you, fail to attract you; you shun them creatively, finding powerful excuses to justify your procrastination.
That is why I was impatient to abduct Sita but avoided meeting you.
This is the wisdom of my life, Rama. My last words. I give it to you." With these words, Ravana died.
Here's Vālmīki's account of how Rāvaṇa immediately died and fell to the ground after Rāma shot him with his brahmāstra:
स विसृष्तो महावेगह् शरीरान्तकरः शरः | च्छेद हृदयं तस्य रावणस्य दुरात्मनः || ६-१०८-१८
18. That arrow, released with great speed and which was capable of destroying the body, tore off the heart of that evil-minded Ravana.
रुधिराक्तह् स वेगेन शरीरान्तकरः शरः | रावणस्य हरन् प्राणान् विवेश धरणीतलम् || ६-१०८-१९
19. That arrow, which was capable of causing death to the body, after taking away the life of Ravana and having been anointed with blood, penetrated the earth.
स शरो रावणं हत्वा रुधिरार्रीकृतच्छविः | कृतकर्मा निभृतवत्स्वतूणीं पुनराविशत् || ६-१०८-२०
20. Smeared with blood on having killed Ravana and thereby accomplishing its mission, that arrow re-entered its own quiver (of Rama) silently.
गतासुर्भीमवेगस्तु नैरृतेन्द्रो महाद्युतिः | पपात स्यन्दनाद्भूमौ वृत्रो वज्रहतो यथा || ६-१०८-२२
22. Having lost his life, that king of demons for his part, who was endowed with terrible swiftness and invested with great splendour, fell down from the chariot to the ground, like Vritra the demon when the latter was struck down by the thunderbolt.