In the case your company does not pay your pension directly, you should make payment to the National Pension Agency on your own.
If you meet the following two conditions, you are legally obligated to opt in to the Japanese pension system.
Condition1) You live in Japan
Condition2) You are at latest 20 years old and less than 74 years old.
If you leave Japan before retiring and you have been paying into Japanese public pension system for 6 months or longer, it is possible that you can receive a lump-sum withdrawal payment. However, once you receive any such withdrawal payment, the period of time used as the basis to calculate future pension benefits will be extinguished. When considering whether to request a withdrawal payment or not, you should consider whether your home country has a bilateral agreement with Japan for totalization of benefits. It may make more sense to apply the time and benefits accrued during your stay in Japan to your pension in your home country if such an agreement exists.