Shulchan Aruch, Yoreh De'ah Siman 356

Siman 356

Presented here for study, not as a practical ruling. The Shulchan Aruch rules by Sephardi custom, the Rema's glosses by Ashkenazi custom, and the Kitzur follows Ashkenazi custom. For a practical question, ask your rabbi.

א מֵת שֶׁלֹּא הָיָה לוֹ צָרְכֵי קְבוּרָה, וְגָבוּ לוֹ וְהוֹתִירוּ, אִם כְּשֶׁגָּבוּ יַחְדָּו לְצָרְכֵי זֶה הַמֵּת, יִנָּתְנוּ לְיוֹרְשָׁיו; וְאִם לָאו, יַעֲשׂוּ מֵהֶם צָרְכֵי מֵתִים אֲחֵרִים.
1 A dead person who did not have [sufficient funds] for the burial needs and they raised [money] for his sake and there was a surplus; if at the time they collected the [money it was done specifically] for the needs of this particular dead person, [the surplus] should be given to his heirs; but if not [collected specifically for this particular person, the surplus] should be used for the needs of other dead.