No 100% perfect answer here, but, personally, I'd go with the foul as occurring before the interception, so B declines and keeps the ball. One thing is for sure - the foul did not give A an advantage. B will be happy to have the ball, so they 'shouldn't' make a big deal out of not getting the added benefit of the penalty, even if video subsequently shows the FMM as occurring after the change of possession.
Mechanically speaking, the covering official needs to keep an eye on those guys, for some sort of retaliation/escalation, so he may not have a great sense of when the foul occurred. The only help he 'might' get would from the off wing, who just might happen to see that the flag was dropped clearly before the interception, meaning the foul HAD to have occurred prior. Otherwise, it is just a 'feel.'