If you do not want certain section headings to be included in the table of contents, you can add two classes to the heading: unlisted and unnumbered. For example:
# Section heading {.unlisted .unnumbered}
Note that this feature requires at least Pandoc 2.10. You may check your Pandoc version via rmarkdown::pandoc_version(). If the version is lower than 2.10, you may install a newer version (see Section 1.1).