This is normal and is called feedback. However, if the hearing aid is doing this after inserted into the ear, something is wrong. This could be several issues. The first thing i would check for is earwax buildup. This is the most common cause and easiest solution. The sounds from the hearing aid are bouncing off the wax and thus "leaking" out around the hearing aid causing a whistling or squealing sound.
The next possibility is poor fit of the hearing aid. Is the hearing aid inserted properly? Is it staying in the ear canal as it should or is it working out of the ear throughout the day? Any of these can cause annoying feedback.
There are other reasons such as circuit noise or poor programming of the device. These are correctable in most cases but needs professional attention.
One more note...
if a hearing aid is whistling on its own or close to whistling on its own...the hearing aid cant operate to its full potential. When a hearing aid, even advanced digital ones, whistles, it has to "concentrate" on getting rid of the whistling that it manytimes cant reach the full prescription of sound for the patient. So, bottom line, whistling isn't just annoying, it can affect the hearing aid performance.