This is a popular story in Japan and can easily be found online in a variety of forms by searching the title (水飴の毒) or 一休ばなし (Ikkyū banashi). The smart apprentice in these kinds of stories is generally named Ikkyū, and you can find several master vs. apprentice type verbal gags by searching 一休ばなし.
Once upon a time there was a stingy master monk who loved to eat mizuame (a kind of candy), but he never shared it with his three apprentices. One day he received a large amount of mizuame and wanted to save it for later.
So he put it in a jar and told his apprentices that for adults, the mizuame was medicine, but for children, it was deadly poison and they would die instantly if they ate it. Saying this, he left to handle his affairs for the day.
The smartest of the three apprentices was named Ikkyū. He told the other two boys that there was nothing to fear and they could eat the candy.
After eating the candy, the other two boys worried that the master would be very angry when he came back. But Ikkyū assured them he had a plan.
He broke an expensive vase and they waited for the master to return.
When the master returned, all three began to cry loudly. The master asked what had happened.
Ikkyū replied, “We decided to clean the temple while you were away, but we broke this vase on accident. We were overcome with guilt and decided to eat the poison candy to atone. We continued to eat until all the candy was gone, but somehow we are still alive!”
The master realized he had been tricked, but was unable to say anything. From that day forward, he made sure to share his mizuame with his apprentices.