RE: Dell Latitude E7270 no audio from internal speakers but headphone jack works
I would run the audio test in the ePSA diagnostic utility, which resides in the BIOS on the motherboard. Its main advantage is that it does not use Windows or Windows-based drivers, so it eliminates those as being the cause of the problem.
If you don't hear the test tones through the speakers, then either the speakers have failed or the connection is loose. However, since your issue is intermittent, if you do hear the tones it doesn't mean there is not a problem with the speakers, particularly if the connection is loose.
If the results of the test seem to be that the speakers are okay, there can be failure in the headphone jack which could also result in your symptoms. The jack can be falsely sensing that there is a plug in the jack when there isn't. There is no dedicated test for that. If Dell replaces the speakers but that doesn't fix the problem, then have them replace the jack, which might involve the motherboard if the jack is not on a separate circuit board.
The gold standard hardware test is to use the Factory Image to restore the laptop to the original factory configuration. Any device that fails to work after doing that, is confirmed to be caused by hardware failure.