You do not describe or provide samples to illustrate the distortion, nor do you give sufficient information to identify the specific lenses you are using. However, it is likely that you are seeing perspective distortion. If that is the case, it is a natural feature of macro photography that is a consequence of the extremely close distance at which you are photographing the subject. It is not a lens defect, and there is little you can do to "correct" it except to move farther away from the subject.
I tried doing what you describe with lenses of various focal lengths. Regardless of which lens I tried (28mm, 35mm, 50mm, 18-55mm, 18-135mm), I get virtually no optical distortion when they are reversed. You can confirm whether there is any distortion by photographing a flat grid.
Although the lenses available to me did not appear to show significant distortion, your lenses may indeed have distortion. Regardless of what software you are using, there is likely no correct way to set lens profiles for inverted lenses or combinations of lenses, some of which may or may not be inverted, because it is not the way the lenses were designed to be used.
However, you do have some options:
If the software you are using allows you to manually enter parameters, you may find settings you like by trial and error.
This is the approach I would take, especially if eyeballing the correction is good enough. Your software may allow you to save presets or templates in which distortion correction settings have already been entered.
If your software uses the
lensfun database, you may attempt to calibrate the lenses yourself for local use. Do not submit your results to the database upstream because that will cause problems for everyone else.
Calibration is a bit involved, and you may have trouble finding where to put the settings for local use. The database format was changed a while back, but even recently, not all software has been updated to use the new format.
You may attempt to individually correct images in Hugin. It is possible to save a
pto file and call Hugin to run on different files. The exact command and how to script it depends on the operating system you are using. It will look something like this:
nona -v -g -m TIFF -z LZW template.pto -o output input.jpg
If you have an unusual level of difficulty, you may consider whether you have "mustache" distortion.