The match was heading for a draw when substitute Ba collected the ball at the edge of the penalty box and shot past goalkeeper Carlos Kameni, sending the capacity crowd into raptures.
After a 1-1 draw at home to the Republic of Congo, the defeat leaves Cameroon with just four points from three games.
Senegal top the group with nine points from three matches and boast the best attack with 12 goals.
Cameroon, playing with top striker Samuel Eto'o on the flank and Achille Webo up front, created plenty of chances but were unable to convert.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.