We're well within the statute of limitations for correctable errors here.
Cancel the successful unmerited free throw point.
Give the ball back to Team B nearest the spot of the foul.
If there had been a foul (like a rebounding foul) during the free throw activity for the unmerited free throw, the foul would be
canceled unless it was unsporting, flagrant, intentional or technical (not relevant here).
Any time that ticked off the clock stays ticked off the clock (
shall not be nullified)(not relevant here).
If any points had been scored between the error and the discovery, other than the unmerited free throw, those points will still count (
shall not be nullified)(not relevant here).
Keep in mind that that a goal (points not nullified) will be immediately followed by a dead ball, which is an important point in the statute of limitations for correctable errors (not relevant here).
Also, keep in mind that a change of possession between the error and the discovery is also important in how to rectify a correctable error (not relevant here).
To avoid many correctable errors (not relevant here), keep your eye on the scoreboard looking for the sixth and ninth fouls (communicate such with your partner) and the noncalling official should identify the shooter.