It's not mentioned in the post. He didn't plan it as part of his original experiment. After his experiment was a success he noticed that his family all had migraines. He decided to try to test if memories could be inherited. It was a separate test the following year with new caterpillars.
Edit: typo