Perhaps:
sed -i "" "${end}s/\\( %.*\\|$\\)/ \\\\cbend{}\\1/" "$OUT"
With saner escaping
sed -i "" "${end}"'s/\( %.*\|$\)/ \\cbend{}\1/' "$OUT"
I did test this before posting:
end=""
{ echo foo; echo "bar % with comment"; } |
sed "${end}"'s/\( %.*\|$\)/ \\cbend{}\1/'
foo \cbend{}
bar \cbend{} % with comment
Since the OP is on a Mac, the sed incantation required is:
sed -i "" -E "${end}"'s/( %.*|$)/ \\cbend{}\1/' "$OUT"