If you are following standards/best practices then you would already have the <h1-6> to identify a header. You do NOT want to use a <p> or a <div> to identify the headers.
When you do that, a ToC is just a button click away!
There are, however, plug-ins that will automagically add headers to your existing ePub.
GenerateHeadings:
https://www.mobileread.com/forums/sh...d.php?t=352025
ReworkChapterHeads:
https://www.mobileread.com/forums/sh...d.php?t=301108
Are a couple of them.