You probably refer to Gemmorah in Avodah Zarah 19a:
אָמַר רַבִּי: אֵין אָדָם לוֹמֵד תּוֹרָה אֶלָּא מִמָּקוֹם שֶׁלִּבּוֹ חָפֵץ,
.(שֶׁנֶּאֱמַר: "כִּי אִם בְּתוֹרַת ה' חֶפְצוֹ"(תהילים א, ב
Rabbi Yehuda HaNasi says: A person can learn Torah only from a place in the Torah that his heart desires, as it is stated: But his delight is in the Torah of the Lord (i.e., his delight is in the part of the Torah that he wishes to study).
THe Gemmorah continues with some examples:
לוי ור"ש ברבי יתבי קמיה דרבי וקא פסקי סידרא סליק ספרא לוי אמר לייתו [לן] משלי ר"ש ברבי אמר לייתו [לן] תילים כפייה ללוי ואייתו תילים כי מטו הכא כי אם בתורת ה' חפצו פריש רבי ואמר אין אדם לומד תורה אלא ממקום שלבו חפץ אמר לוי רבי נתת לנו רשות לעמוד
The Gemara relates: Levi and Rabbi Shimon, son of Rabbi Yehuda HaNasi, were sitting before Rabbi Yehuda HaNasi, and they were learning the Torah portion. When they finished the book that they were learning and were ready to begin a new subject, Levi said: Let them bring us the book of Proverbs; and Rabbi Shimon, son of Rabbi Yehuda HaNasi, said: Let them bring us the book of Psalms. He compelled Levi to acquiesce, and they brought a book of Psalms. When they arrived here, at the verse: “But his delight is in the Torah of the Lord,” Rabbi Yehuda HaNasi explained the verse and said: A person can learn Torah only from a place in the Torah that his heart desires. Levi said: My teacher, you have given us, i.e., me, permission to rise and leave, as I wish to study Proverbs, not Psalms.