I'm not sure what .ram is, but .dmg is a disk image. A disk image is a file that mounts like a hard drive on your mac. Most software is distributed this way. You download the disk image and it mounts on you mac, showing you the contents. You then copy the contents to your hard drive. Specifically, if it is an application, you copy it to your /Applications folder. Once you have copied the content out of the mounted disk image, you can do whatever you want with the .dmg file.
If you want to keep it on your Mac in case you need to re-install the app, then do so. If you want to archive it on a CD or DVD, go ahead and do that.
If you just want to throw it away, just drag to trash and empty the trash.
However, you must eject the disk before you can do anything with the dmg file. On the Finder sidebar, next to the mounted volume name, there should be an eject button. If it won't eject, the mounted image is busy. Make sure you didn't launch the app from the mounted image. If you did, quit the app and copy it to /Applications. Then, you should be able to eject.