Surprise onside kick attempts are generally worth the gamble. Based on the Expected Points model, a normal kickoff is typically worth -0.42 EP, as the opponent has a 1st down at about their own 22. A recovered onside kick (1st down at one's own 45) is worth 1.77 EP. A failed onside kick (opponent's 1st down a one's own 45) is worth -2.36 EP. The break-even recovery probability would therefore be:
1.77 * x - 2.36 * (1-x) = -.42
4.13 * x = 1.94
x = 0.46
From 2000 through 2012, surprise onside kicks have been successful 53% of the time. Since 2009, when rule changes prevent unbalanced kickoff formations, they've been successful only 33% of the time. But we shouldn't expect the rule change to affect surprise onside kicks, because an unbalanced formation would betray the kicking team's intent. So it's likely the drop is due to small sample effects, as there were only 39 surprise attempts since 2009. (It's also possible that the Saints' surprise onside kick to open the second half of the 2009 season Super Bowl may have alerted coaches to the tactic.)
As 53% is greater than 46%, in general, onside kicks are worth the risk when the kicking team has the element of surprise. The receiving team's tendencies are essential to the analysis, and the tactic is best as an option play depending on how the receiving team is aligned and whether they respect the possibility of an onside attempt.
What does Win Probability say? The game was early in the 4th quarter and BAL was trailing by 4 points, so a gamble might be more worthwhile than otherwise. A successful recovery would be worth a 0.38 WP. A failed attempt would be worth 0.22 WP. A conventional kickoff would be worth 0.29 WP. The break-even recovery probability would be:
0.38 * x + 0.22 * (1-x) = 0.29
x = 0.44
It appears the game was still somewhat in "normal football" mode at this point, as the WP and EP models were in relatively close agreement.
Ultimately, coaches would like to see tendencies on the front line of the receiving team before trying a surprise onside kick. Without that kind of analysis, it's impossible to pass a verdict on particular instances. But in general, all things being equal, surprise onside kicks are worth the risk, and this case was no exception.
Of course, all the Monday morning quarterbacking this week in Baltimore is focused on this play and not on BAL's successful 4th down conversion on the previous possession.