Typically, Lightroom, Photoshop ACR, or Bridge, though there are now many other products that use "sidecar" files, including Nikon Capture NX-D. If you used any of those products to do much of anything (sometimes even just viewing) an image, they'll create a companion XMP file with the same name. That's where they store changes, collect preview images they've made, add IPTC data, and place changes to EXIF data. The nice thing is that the original image file is untouched. The not so nice thing is that the XMP file really needs to follow the original file around if you want to have access to your changes (one reason why we have a database-tracking application like Lightroom in the first place).
Nikon's method used to be different than Adobe's. Nikon once stored changes you made via ViewNX2 or Capture NX2 within the original file itself. The good news is that that meant the changes were always with your file, but it also meant you're constantly writing to your original file and it grew in size. Plus that file format is proprietary, which means that not all other programs understand the Nikon changes (see this). Nikon changed this with NX-D, which uses sidecar files like Adobe.
There's no one right solution to the problem. Both ways of dealing with tracking changes have their pluses and minuses. For Adobe (and other) products that create XMP, I try to keep a strict file structure so that XMP files are always with my originals.