Usually on a 7 or 8 night cruise, there's 2 formal nights. I don't know the exact nights they may be on, but I can tell you which nights they're most likely not on: the first and last nights. On the first night, people are usually tired from traveling and unpacking or don't have their luggage delivered to their room yet, which is why it's typically a casual night. On the last night of the cruise, people are typically packing and are tired from doing that. Some might have packed their formal clothes and set them out early to be collected by the staff for the following day's disembarkation. Hence why, the last night of the cruise is typically a casual night as well.
The rest are usually anybody's guess, but they normally tell you about that a day in advance in the Cruise Compass or the app. You can use the app for free using the ship's wifi and it will allow you to view the menus there as well as making any dining reservations.