Hadithcore
Sahih al-Bukhari, 3755
sahih

Narrated Qais:

Bilal said to Abu Bakr, "If you have bought me for yourself then keep me (for yourself), but if you have bought me for Allah's Sake, then leave me for Allah's Work."

حَدَّثَنَا ابْنُ نُمَيْرٍ، عَنْ مُحَمَّدِ بْنِ عُبَيْدٍ، حَدَّثَنَا إِسْمَاعِيلُ، عَنْ قَيْسٍ، أَنَّ بِلاَلاً، قَالَ لأَبِي بَكْرٍ إِنْ كُنْتَ إِنَّمَا اشْتَرَيْتَنِي لِنَفْسِكَ فَأَمْسِكْنِي، وَإِنْ كُنْتَ إِنَّمَا اشْتَرَيْتَنِي لِلَّهِ فَدَعْنِي وَعَمَلَ اللَّهِ‏.‏

References2 variants
In-Book Reference
Book 62, Hadith 100
USC-MSA web (English) reference
Vol. 5, Book 57, Hadith 99 (deprecated numbering scheme)