In order to diagnose what could be wrong, we need to see some of the photos you are having trouble with. Can you post one of the underexposed photos with the EXIF data still embedded? That way we can look at the camera settings and see where the problem might lie.
Are you sure you aren't shooting beyond the capabilities of the flash? The ability of a flash to light the subject is dependent on the subject distance and the f/stop used. If you are too far for a particular f/stop, the subject will be underexposed.
Try checking the subject to flash distance and compare it to the maximum power of the flash. Every flash has its limits.
You can derive that limit from the guide number of the flash. The GN for your popup flash is 15 feet at ISO 200.
Here's a table from Steve's Digicams that shows the range of the the D50 flash based on that GN -

So if you are shooting at f/8 at ISO 200, the flash is only good from 7 feet away. Any further and you will begin to see underexposure. Stop down to f/22 and you max flash distance is reduced to 2.4 feet.
If you are further away than this table indicates at the given ISO and f/stop, you will get underexposure.
If this isn't the problem, you could post a photo here with EXIF data (many jpgs still have exif data intact).
If we can't help, before I sent my camera in to Nikon, I would post your query on the D50 forum of DPreview.com. Search the forum first for flash underexposure to make sure it hasn't been posted 1000 times, then ask the question.
It will help them (or us) if you can post a picture with intact exif data that shows the problem.
-----
Chris Harrison
San Antonio, Texas