I don't personally do that optimization, but what I understand from those that do is the easiest way to do this is to put a small sticky on each card with the categories that it should be used for. So card A has "groceries, eating out, cell phones" written on it, card B has "home improvement, movies, gas", etc. Both spouses carry all active cards at all times and commit to looking at the stickies and using the correct card for each category. One spouse usually takes on the effort of figuring out the card+category combinations.
Some cards, of course, have more complicated cash back schemes (rotating categories, cashback only up to a certain amount) and those take more effort to manage. I'm not sure how people do that exactly except maybe the one person who figures out the combinations also tracks the rotations and spending caps and updates the stickies more frequently.
I understand the motivation and the optimization, but the cost/benefit ratio isn't there for me personally, so I don't have a better answer for you than that.
Good luck!