A TOC is made up of paragraph styles that you specify in Inspector > Document > TOC
This screen shot shows Heading 1 as a TOC Style. Heading 2 is greyed out because there are no paragraphs with that style in the document.
View > Show Styles Drawer to apply a style to a paragraph.
The TOC searches downwards. Click at the top of the document then Insert > Table Of Contents. It is highlighted in blue because it is selected. You can add more chapters later. Click on the TOC to update it.