Rambam seems to refer to this incident in the gemara in two different places, with subtle differences.
In Hilchot Sanhedrin 24:4 he writes:
יֵשׁ לְבֵית דִּין לְהַלְקוֹת מִי שֶׁאֵינוֹ מְחֻיַּב מַלְקוֹת וְלַהֲרֹג מִי שֶׁאֵינוֹ מְחֻיַּב מִיתָה וְלֹא לַעֲבֹר עַל דִּבְרֵי תּוֹרָה אֶלָּא לַעֲשׂוֹת סְיָג לַתּוֹרָה. וְכֵיוָן שֶׁרוֹאִים בֵּית דִּין שֶׁפָּרְצוּ הָעָם בַּדָּבָר יֵשׁ לָהֶן לִגְדֹּר וּלְחַזֵּק הַדָּבָר כְּפִי מַה שֶּׁיֵּרָאֶה לָהֶם הַכּל הוֹרָאַת שָׁעָה לֹא שֶׁיִּקְבַּע הֲלָכָה לְדוֹרוֹת. מַעֲשֶׂה וְהִלְקוּ אָדָם שֶׁבָּעַל אִשְׁתּוֹ תַּחַת אִילָן.
A court has the authority to administer lashes to a person who is not required to receive lashes and to execute a person who is not liable to be executed. This license was not granted to overstep the words of the Torah, but rather to create a fence around the words of the Torah. When the court sees that the people have broken the accepted norms with regard to a matter, they may establish safeguards to strengthen the matter according to what appears necessary to them. All the above applies with regard to establishing directives for the immediate time, and not with regard to the establishment of halachah for all time. An incident occurred where they had a man lashed for engaging in relations with his wife under a tree.
(Touger translation)
This seems to imply that what the man did in this case is not ordinarily deserving of any punishment. He was punished exceptionally, as the court of that time and place saw fit.
In Hilchot Issurei Biah 21:14 he writes:
וְאָסוּר לְאָדָם לָבֹא עַל אִשְׁתּוֹ בַּשְּׁוָקִים וּבָרְחוֹבוֹת אוֹ בַּגַּנּוֹת וּבַפַּרְדֵּסִין אֶלָּא בְּבֵית דִּירָה. שֶׁלֹּא יֵרָאֶה כִּזְנוּת וְיַרְגִּילוּ עַצְמָם לִידֵי זְנוּת. וְהַבּוֹעֵל אֶת אִשְׁתּוֹ בִּמְקוֹמוֹת אֵלּוּ מַכִּין אוֹתוֹ מַכַּת מַרְדּוּת.
It is forbidden for a man to engage in relations with his wife in the marketplaces, streets, gardens, or orchards. Instead, [a couple should be physically intimate] only in a home, so that they will not appear as licentious relations and will not habituate themselves to licentious relations. When a man engages in relations with his wife in such places, he should be given stripes for rebellious conduct.
(Touger translation)
This seems to imply that any act of public intercourse is punished (rabinically) by lashes. It is not left to the discretion of the local court.
R. Yosef Rozin in Tzafenat Pa'aneach to Issurei Biah 21 resolves the contradiction as follows:
Intercourse in a public place (such as a marketplace or a main thoroughfare, or even a garden or orchard) is indeed always punished (rabbinically) with lashes. However, in the case under discussion in this question, the incident took place beneath a fig tree, which provided at least minimal seclusion.
That being the case, this act was not, strictly speaking, deserving of lashes at all, even rabbinically. However, the judges at the time exercised their prerogative to administer lashes in any event, in order to further the orderly running of society.