When I plug earphone in my phone all the volume get low automatically
It sets the volume to the last volume level you set while you are still plugged in. It's normal. Also, it automatically lowers after sometime as a protection to your hearing if your volume is too high.
This is just a good feature provided by some good brands these days. This feature helps you to adjust the voice according to your requirements.
You might also notice that once you remove your earphones the music in the background stops this is also a part of this feature.
You dont need worry about about it its just a good feature.
And if all the volume including your phone ringing gets slow then i would recommend you to update your system software which might fix this issue