Flag goes up for offside - play on until the ball dies (goal, goalkick, throw, whatever), or the opposition regain posession - if a goal is scored, check for offside and rule accordingly, if he was offside freekick from where it happened. Clock/time? Feck it and add it at the end if need be.
Simple.
EDIT: If the opposition regain posession, play-on ignoring the free kick (1 less stoppage in play).
Or,
Regain the ball, take a freekick from where the offside happened if it was offside.
No idea how to figure out that part actually, so perhaps not so simple.
I like option 1 of the edit.