I looked up the NFL rules at https://operations.nfl.com/the-rules/nfl-rulebook/.
By rule 3 section 35, whichever team has possession is offense, and that can change during the down, so under that rule once the receiving team catches the punt, the kicking team is now defense. Thus by rule 4 section 8 article 2(a), the half can't end on a penalty they commit then.
What about penalties while the kick is still in the air? Rule 4 section 8 article 2 has some extra rules such that basically any penalty by the kicking team extends the half if committed after the kick, even when the kicking team is technically still on offense because the receiving team doesn't have possession yet. The kicking team downing the punt by touching it first does it too.
By rule 3 section 35, whichever team has possession is offense, and that can change during the down, so under that rule once the receiving team catches the punt, the kicking team is now defense. Thus by rule 4 section 8 article 2(a), the half can't end on a penalty they commit then.
What about penalties while the kick is still in the air? Rule 4 section 8 article 2 has some extra rules such that basically any penalty by the kicking team extends the half if committed after the kick, even when the kicking team is technically still on offense because the receiving team doesn't have possession yet. The kicking team downing the punt by touching it first does it too.

