Just to support what other have said, the temps really are too high, it may be one of the reasons why it´s terrestrial. This species arrives to pet-shops in a bad shape generally, and if kept warm they are very susceptible to infections, so it´s very important that you low the temperature to below 20ºC to give the animal a chance to recover from all the stress...it´s inmune system will work best at low temps.
If it really is eating the pellets, they are fine, but you really should offer a variety of foods, earthworms being the best. Using one food as a staple rarely works well, because it leads to deficiencies.
I also second that you need a bigger tank. 3 gallons is way too small . The minimum would be a 10gallon, as mentioned above, mostly because with less volume it´s practically impossible to keep a tank healthy long term. A 10gallon will allow you to maintain water quality easily, and will provide with enough room for the newt to swim when it becomes aquatic. Being in such a small tank is probably another reason why it is terrestrial. The water quality is most probably not ok (specially with the high temp), and since they can sense it, it´s staying away from it.
The final reason why it may be terrestrial is that with a length of 5cm it´s probably still a juvenile. That means it is completely terrestrial, and in fact there´s a possibility of drawning. They usually don´t become aquatic until they mature. If there are no signs of it becoming aquatic, i´d transfer it to a fully terrestrial tank, at least until it becomes an adult, and then goes to water.