First, an offence can only be considered to be a foul, if it is committed by a player, it must happen within the play area, and lastly, it must occur when the ball is in play.
If these conditions are met, while an offence is committed the proper restart of the game would be a direct free kick from where the ball was last located.