My understanding of the NFL rule in this regard (from an NFL official) is that it is considered continuing action so it is part of the play. Since the foul was behind the LOS, it would have been enforced from the previous spot which was fewer yards than the sack itself. Someone can correct me if I am incorrect.