He almost certainly gets paid for his cameos, but the amount of money he gets could be quite paltry, especially in comparison to the fortune he has played such a vital role in creating for Marvel.
Stan gets paid for being Stan the Man. Stan gets paid for being Executive Producer. Stan gets paid for his gratuitous cameos. Stan Lee has made himself famous. He is the Kardashians of the comics world and he is making himself rich, still, at 89 years old with the same vigor he had in 1961 when the Fantastic Four first hit the stands.
It is tricky to talk about how much money he probably makes for each cameo, but this much is pretty much a given: In major movie productions, the extras are almost always compensated for their time and efforts, although the specific amount each extra earns is dependent upon several factors.
Time spent on set. Obviously, more time means more money.
Dialogue. If you say something on camera and it is clearly audible in the finished movie, you get paid more than someone who doesn't say anything on camera, or whose dialogue is lost in background chatter. Extras who get the opportunity to say something on camera are referred to as "Day Performers", whereas extras whose voices are not heard are called "Background Extras".
Membership in the Screen Actors Guild. S.A.G. is like a union, and it requires that all productions that sign a contract with S.A.G. abide by certain regulations. Among these regulations are the rates offered to actors who appear in the production, and who are members of S.A.G. S.A.G. membership makes things even more complicated, because it appears that they have different police from one place to the next, at least regarding minimum rates.
Assuming that Stan the Man is a S.A.G. member, which seems very likely1, and has been suggested in a few articles, he can expect to earn a whopping total of about $150 per day2 on set for a non speaking role, and he could possibly get a bit more3 thanks to standard allowances for meals, overtime, supplying your own wardrobe, etc.
If his cameo calls for him to actually say something, his earnings sky rocket to the unimaginable heights of roughly $8502, again with the possibility of a few extra bucks for lunch, wardrobe, and overtime.
The figures listed above should probably be taken as the absolute minimum amount Stan is likely to have earned for his cameo performances, and it is very easy to imagine him making much more than that by virtue of his popularity and cache. It is extremely difficult to suggest the maximum amount of money he might have made.
It is also possible that Stan Lee doesn't make a dime for his cameos, but it seems very, very unlikely. In order for him to do his cameos pro bono, he would have to have made a deliberate choice to not become a member of S.A.G., and he'd also have to be willing to spend considerable amounts of his own money to take part in filming. Since he charges at least $100 for a measly autograph, I can't imagine he would forgo the opportunity to make a bit of folding money when he gets a chance. And even if we assume that Stan doesn't realize that his time is worth a fair amount of moolah, he would still get all his travel expenses, food, lodging, and incidentals paid for by the studio. But this is almost unquestionably a moot point, because it is virtually impossible to conceive of a world in which Stan the Man doesn't receive at least nominal compensation for his time and energy.
1 You are eligible for membership in S.A.G. after you have three stints as a Background Extra under your belt, which Stan has already done. More importantly, Stan almost always gets a credit as producer on MCU films, and since Marvel is presumably eager to remain in the good graces of S.A.G., he probably would have gotten a membership card for his behind the scenes roles even if he never set foot in front of the cameras.
2 Screen Actors Guild website Rate Sheet PDF
3 Old Screen Actors Guild Rate Sheet for NY area