Should I "just do it"?
Nope, never. If the person is not aware and you accidentally surprise them, it can lead to an awkward conversation that nobody wants.
Or should I be a gentleman and say something like "Kind Lady, be advised I wish to go under the desk"? Or is that sexist?
Using any term that refers to the person's gender in order to get that person's attention can be taken as being sexist. To get a person's attention and not someone else's attention it works best to use something that uniquely identifies them, like their name or job title. By using their gender it caries undertones that the speaker considers their gender a superior way of identifying that person and thus be interpreted as sexist.
Being Courteous Wins
HorusKol's answer nails this so I will not say anything else on it.
How to Handle Follow Up Questions
Odds are the coworker is not going to care that you are going under your desk to work, but will appreciate being informed even if they do not mention it. However, there is a rather slim possibility they may ask a question that might leave you in a tight spot like:
Why are you bothering to tell me?
At this point if one was to say something to the affect that they are trying to avoid the appearance of looking up someone's skirt would create unnecessary tension and awkwardness even when well worded. The best thing is to deflect any concerns with using an 'I' based explanation that has nothing to do with gender, and is fundamentally based on courtesy:
For me if someone was going to be crawling under their desk next to mine, I would want to know about it as a common courtesy. I also would want to save my work in case they accidentally bump the power switch on my power strip causing me to lose any unsaved work.
There are other things that can be used such as pointing out that COVID-19 has made people more sensitive about others getting within 6 feet of them without any kind of warning or getting permission. Also if their desk is an opposing desk. Then an additional statement about not wanting to accidentally get kicked while under the desk can also be used.
The most important part of the deflection is not to bring up gender. There are many reasons besides gender for informing the other person about going under one's desk. As such if the reason given is because of gender, that indirectly communicates that the speaker considers the other person's gender as more important than any other reason and thus can be construed as being sexist.
Typically a person does not stay in their desk for 8 hours without getting up to take a break of some kind. If the work that needs to be done under the desk can be delayed to one of those times, the whole situation can be avoided.
HorusKol's answer about getting an extension lead or something similar is also a great option to help permanently solve this.