The head of the Office for Budget Responsibility, the watchdog that marks the Treasury's homework, has resigned after the organisation inadvertently leaked all of last week's budget two hours early.