Ok, how you find out...your TA or
DCL (if you booked directly) calls you and says "DCL is offering you a cabin upgrade. Your new cabin would be XXXX, which is a category Y. Do you want the upgrade?" Since it was after I already had my documents, I was instructed to write in the new cabin number on my luggage tags, preferably in black marker.
As to who gets free upgrades, it seems totally random. The bottom line is that DCL wants to fill ships. The closer the sailing date is with the ship not full, the lower the prices might go. If the ship is still not filling, they but category 11 is nearly full, they may upgrade some people so that new people can purchase cat 11 at cheap rates. It is still better for them than sailing with empty cabins.
Sometimes, you can purchase an upgrade at the port cheaper than it would have been to book the higher cabin initially. Frequently, they have a sign up that says "no upgrades." The bottom line is that you can never count on upgrading, whether free or purchased. You need to buy a category that you will be happy staying in. If you get upgraded from that, consider it a bonus.