Several ideas come to mind, but I see the examples more as 'dad jokes' and I'm not quite sure I see how "[in] both cases the compliment was clearly accepted," so that may colour my responses (but feel free to steer me in the right direction if I'm mistaken).
Based on my interpretation, rapartee
is what I'm hearing you describe. From Merriam and Cambridge:
rapartee
- a. quick and witty reply
b. a succession or interchange of clever retorts : amusing and usually light sparring with words
- adroitness and cleverness in reply : skill in repartee
Usage note: REPARTEE implies the power of answering quickly, pointedly, or wittily
quick and usually funny answers and remarks in conversation:
Oscar Wilde's plays are full of witty repartee.
Other ideas along the same lines are: quip
, rejoinder
, bon mot
, witticism
("often...ironic remark" Merriam), wisecrack
(clever or sarcastic remark).
Again, I don't see how the "compliment was accepted", but some of the other answers capture that and could be combined with words from above. For example: a self-effacing wisecrack or a self-deprecating quip.
A few other words more in the direction of "self-effacing" or generally "not serious" come to mind (Cambridge):
facetious
not serious about a serious subject, in an attempt to be funny or to appear clever
Usage note: Some common synonyms of facetious are humorous, jocose, jocular, [waggish], and witty. While all these words mean "provoking or intended to provoke laughter," facetious stresses a desire to produce laughter...ill-timed attempts at wit or humor
Sardonicism tends to be but is not necessarily dark/malicious, that is clever and playful, while also not being overly broad.
Here's a definition and example from the same site:
Sardonic
Sardonic is an adjective describing dry, understated, and sort of mocking speech or writing—such as a clever remark that stings because it’s so accurate. While sardonic comments seem slightly hostile, they are supposed to be witty and humorous rather than deeply hurtful.
I did not attend the funeral, but I sent a letter saying I approved of it. (Mark Twain)