Create bookmarks in pdf
There are many ways for crating TOC in PDF. Best one is probably using pdfmarks file which exposes all possibilities described by Adobe pdfmarkReference
It's not that hard to programatically parse PDF documents and collect needed information for creating this pdfmarks files, which afterwards can be embedded in PDF file by using GhostScript i.e.
For an easy way of manually adding TOC entries, like you want I assume, PDFMod GUI utility can help. It's listed in Synaptic
To supplement zetah's answers, here's a quick tutorial on how to create a pdfmarks file and use ghostscript to add that to a PDF file:
http://milan.kupcevic.net/ghostscript-ps-pdf/#marks
The syntax is a bit arcane, so you will probably need another tool to generate those files.