The slokha is
"Avasyam anubhogthavyam kritham karma subha asubham; naa bhugtham ksheeyathe karma kalpa koti sathairapi"
Is it from vedas or puranas or any other text?
The sloka is from Brahmavaivartha Purana. It exist in Prakriti Khanda and at multiple places.
First there's verse 71 here: http://www.hinduscriptures.in/Content/Articles/PDFs/30831/77f_chapter_56_2.pdf
Then there's verse 17 of this chapter: http://www.hinduscriptures.in/Content/Articles/PDFs/30776/77f_chapter_67.pdf
3.Then verse 56 of this chapter: http://www.hinduscriptures.in/Content/Articles/PDFs/30811/77f_chapter_89_1.pdf
Courtesy: Keshav Srinivasan