Removing two letters only if they appear at end of a field in QGIS labels

One possible expression would be:

CASE WHEN
RIGHT("name", 1) IN('a', 'o') 
THEN substr("name", 0, length("name")-1)
ELSE "name"
END

In addition to your right("name",1), substr() part works to remove 1 letter from the original length of the "name" field.

enter image description here


You could use regex_replace

function regexp_replace

Returns a string with the supplied regular expression replaced.

Syntax regexp_replace(input_string,regex,replacement)

Arguments

input_string the string to replace matches in

regex The regular expression to replace. Backslash characters must be double escaped (e.g., "\s" to match a white space character).

replacement The string that will replace any matching occurrences of the supplied regular expression. Captured groups can be inserted into the replacement string using \1, \2, etc.

So in your case something like:

regexp_replace("name",'[ao]$','')