How to recognise when to stop training based on Overfitting/Underfitting?
Overfitting : 


  The model tries to memorize what it has learned. Hence, it could not
  classify unseen samples.


In case of overfitting, the validation accuracy stops increasing and the validation loss also does not decrease.

It means that the model can no more generalise itself to get a validation accuracy above a certain threshold.

Hence, you can stop the training, when the val_acc does not change for a specific number of epochs.

Underfitting : 


  Underfitting means that model is not able to classify any of the
  samples even after learning them.


The model should stop its training when the accuracy and loss seem to be constant or they only revolve around a certain value.

In your case :

The loss for the train as well as test  seem to decreasing simultaneously. The test curve flattens a bit earlier. It could be treated if the learning rate is decreased.

Tip: If you are using Keras, try the EarlyStopping callback.