To check if you need an apostrophe do this simple exercise:
Example 1
1. The original sentence.
- The teachers class.
2. Now write it with of.
- The class of the teacher.
3. Looks good.
4. So, we use an apostrophe.
- The teacher’s class.
Example 2
1. The original sentence.
- Ten weeks old.
2. Now write it with of.
- Old of ten weeks.
3. That doesn’t work.
4. So, we don’t use an apostrophe.
- Ten weeks old.