The short answer
Under ~12 seconds, foul before the shot goes up. Not a reach on the catch, not a gamble — a foul on the floor, before any shooting motion starts, on their worst free-throw shooter. Two makes can't beat you. A three ties it. Fouling takes the three off the board entirely and trades it for a coin flip you control.
Between about 13 and 30 seconds, it's too early. If you foul now, you hand them a fresh possession with almost half a minute left — that's a gift, not a stop. Guard the arc, switch every screen, and do not put a hand on a shooter. Wait for the clock to bleed down under ~12, then take the foul — ideally landing it in the 4–8 second window, and never with under ~4 seconds, where the contact bleeds into the shooting motion.
The one thing that changes the call
If the other team owns the offensive glass, fouling gets more dangerous, not less. The real risk isn't the made free throw — it's the missed second free throw bouncing right back to a crashing offensive rebounder for a putback three or an and-one. If they're out-rebounding you, get two bodies committed to boxing out the free-throw shooter before you commit to the foul. If you can't trust the box-out, defending the arc straight up is the safer call, even under 12 seconds.
What if you have a foul to give?
This is the part most coaches miss. If your team hasn't reached the bonus yet this quarter, a foul in that 13–30 second window doesn't send anyone to the line at all — it's free. Spend it early in their dribble, not on a shooter, and it does two things: it burns 5–8 seconds off the clock as they re-inbound and reset, and it blows up whatever set play they just called. You're not foul-up-3-fouling yet. You're just making them start over.
One thing to track in your head (or let the app track for you): once that foul puts them in the bonus, you're out of free ones. The very next foul is live. Know exactly how many you have left before you spend the last one.
Who gets the foul
Don't leave this to whoever's closest. Before the situation ever comes up, know your roster's actual free-throw shooters — the guard shooting 45% from the line is a very different foul than the one shooting 80%. And don't put your leading scorer in early foul trouble doing it; the ideal fouler is a bench player or a big with fouls to spare, not your best player two away from disqualification.
The full margin picture
Up 3 is the headline case because the math is cleanest, but the same before-the-shot logic scales — the reasoning changes as the lead gets bigger. Up 1 or 2, a two-point make still loses you the lead, so whether to foul depends heavily on how well the other team shoots free throws. Up 4 or more, a three doesn't tie the game anymore, so fouling stops making sense entirely — you just play defense and make them execute in the half-court. The free interactive decision chart below walks every margin, not just up 3 — set your own score, clock, and matchup and get the call in real time.
Why this is worth having in your pocket during the game
None of this is complicated once you've seen it laid out — the hard part is remembering it cold, at the exact moment the clock says 0:14 and your stomach says "just foul." Courtside AI runs this same chart live, during your game, and it already knows your actual roster's free-throw percentages — so instead of "foul their worst shooter," it tells you the name.