Assuming you are using NF football rules the DPI would be penalized from the previous spot. DPI, by it's very definition, is a foul that occurs during a loose ball play. All defensive fouls that occur during a loose ball play are penalized from the previous spot.
Team A would have the choice of taking the results of the play OR taking a 15 yard penalty from the previous spot and an automatic first down.
In this situation the yardage penalty cannot be "tacked on" to the end of A's run.
------------------
|