It doesn't have to be on-chain. The blockchain is only used in case of a dispute between the parties involved. In that example they say dave claims his payment by broadcasting a transaction on-chain and in doing so reveals the secret allowing bob to get paid too. But in practice dave would simply reveal the secret to bob off-chain and keep the payment channel open for future transactions.
Also you should read the official lightning docs section for HTLCs because it's a little more complicated than that in practice:
https://github.com/ElementsProject/lightning/blob/master/doc/deployable-lightning.pdf