How do I use this? Or where do I put it to make it work?
According to http://support.github.com/discussions/repos/4299-auto-generate-table-of-contents-in-wiki-pages this can no longer work.
I developed GitHub Wikifier: A pre-commit Git Hook that will generate all the Table of Contents you will ever need. Just write your content, and let it take over. May be worth a check. https://github.com/kuroir/GitHub-Wikifier