كتاب الإيمان
1  
The Book of Faith
(53)
Chapter: Will a person be punished for his actions during the Jahlilliyyah?
(53)
باب هَلْ يُؤَاخَذُ بِأَعْمَالِ الْجَاهِلِيَّةِ
Sahih Muslim 120 b

It is narrated on the authority of Abdullah b. Mas'ud:

We once said: Messenger of Allah, would we be held responsible for our deeds committed in the state of ignorance? He (the Holy Prophet) observed: He who did good deeds in Islam would not be held responsible for what he did in the state of ignorance, but he who committed evil (after having come within the fold of Islam) would be held responsible for his previous and later deeds.
حَدَّثَنَا مُحَمَّدُ بْنُ عَبْدِ اللَّهِ بْنِ نُمَيْرٍ، حَدَّثَنَا أَبِي وَوَكِيعٌ، ح وَحَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، - وَاللَّفْظُ لَهُ - حَدَّثَنَا وَكِيعٌ، عَنِ الأَعْمَشِ، عَنْ أَبِي وَائِلٍ، عَنْ عَبْدِ اللَّهِ، قَالَ قُلْنَا يَا رَسُولَ اللَّهِ أَنُؤَاخَذُ بِمَا عَمِلْنَا فِي الْجَاهِلِيَّةِ قَالَ ‏ "‏ مَنْ أَحْسَنَ فِي الإِسْلاَمِ لَمْ يُؤَاخَذْ بِمَا عَمِلَ فِي الْجَاهِلِيَّةِ ‏.‏ وَمَنْ أَسَاءَ فِي الإِسْلاَمِ أُخِذَ بِالأَوَّلِ وَالآخِرِ ‏"‏ ‏.‏
Reference : Sahih Muslim 120b
In-book reference : Book 1, Hadith 226
USC-MSA web (English) reference : Book 1, Hadith 218
  (deprecated numbering scheme)