@melfnt already posted a comprehensive answer using a code. Here's another way to arrive at the same solution with a recursive approach:
Let's build the cases from the ground up. First, we'll solve the same problem with only 1 card. How many flips do we need, at most? The answer is obviously 0, the single card is either face-up or face-down, and we are happy either way.
Then, we'll try to see if we can do the same with more cards. The way to do this is to pick any card as a pivot, and then split the situation into three phases.
- Apply the N-1 cards solution to the non-pivot card(s).
- Flip the pivot card
- Redo the flips from phase 1 in reverse order.
The first phase is guaranteed to visit either a "all face up" or a "all face down" state for the N-1 cards. If we were lucky, the pivot card was already the correct way up, but since we need to be sure, we'll have to assume the pivot was the wrong way up. So, we flip the pivot and redo the first phase, but this time we perform the moves in reverse order! This makes the non-pivot cards go through all the same states as in phase 1, including the same "all cards the same way" state as before, so with our pivot now flipped, we are guaranteed to hit the desired solution state now, if we didn't hit it before.
Then, it's time to calculate the required number of flips.
Since we already know that the 1-card situation takes exactly 0 flips in the worst case, we get that the two-card variation takes 0 + 1 + 0 = 1 flip. This also makes intuitive sense: either the two cards were already the same way up, or they weren't, in which case flipping either card fixes that.
Continuing with the same method, the three-card version takes 1 + 1 + 1 = 3 flips, the 4 card version takes 3 + 1 + 3 = 7, and so on.
Since we don't want to do the tedious addition all the way up to 7 cards (I mean, three more additions? Ain't nobody got the patience for that!), we can notice that adding a card doubles the number of steps needed, and adds one. This also happens to be a formula for generating the next number of form $2^n-1$, assuming you started with a number that was also of that form. Seeing that our 1-card case coincides with $2^0-1 = 0$ then, we get that the general formula for $n$ cards is $2^{n-1}-1$ flips, so we finally get that the solution for 7 cards is
$2^{7-1}-1 = 2^6-1 = \mathbf{63}$ flips.