Your question is not specific to PyTorch. You’re asking about generalization, which at the core of machine learning. There is no simple answer, sadly.
Have you tried adjusting the learning rate or the amount of L2 regularization?
Also, note that about 8-10% of difference in accuracy from training to valid/test is not uncommon.