MacBook charge

I have a MacBook that I use only a few times a year. Should I keep it constantly charged? If I keep it uncharged and charge it only when I need it, would that cause any damage? Or doesn’t it make any difference?

For absolute longest battery lifespan, storing the battery at about 40% of it’s full charge is best. However, you then need to remember to charge it before you need it. If you truly only use a few times a year, that might work for you.

I may be missing something, but . . . how do I keep the charge at 40%? It starts gaining charge as soon as it’s plugged in, and losing when it’s unplugged.

You don’t.
You either put it away charged, or you leave it plugged in all the time. Not charging it all the time will probably extend the battery life by some small amount. There’s no option for an “extended life” charge.