You can do it at any time... here is how it works... if you ever scratch - you owe a ball.. you know that, foul / scratch = owe ball..
if you pocket a ball in your hole, and follow it in - you spot that ball you made up, and you still owe one (because you fouled). ANY ball you make when you scratch is automatically null and should be spotted... the only exeption is... if you make a table foul (double-hit, push shot, etc) and pocket a ball in your opponents pocket - it DOES count for them... but not if you just fling the cue-ball off the table when you make their ball, or if you scratch...