Reasons why castling may be the only winning move I recall at least one game of mine where my last move was castling (around move 20 or so :-), it saved my ugly posterior, it was the only move and we immediately agreed on a draw after that. (Do not try this at home, kids.)
I see the following ways of castling being the only winning move.

Retro: Under some convention, one side castles to prove the other can't.
Tactical 1: Again, the king's posterior is on fire, and after that is solved, material wins. (Happened.)
Tactical 2: Double attack on a stupid incoming Rb2 and Kd8 - yes, that happened more than once.
Tactical 3: E.g. after some Nxf2 against the bK, with great shocking value. Ditto. So lets file everything else in this spirit under &quot;Various Tactical&quot;.
Positional: This is the only way to get the rook past the king and out of the pawn forest. (Very study-like. Probably never happens in a game.)

What are other ways in which castling may the only winning move in any given position?
Castling is an incredibly useful in chess: three moves in one. So we don't have to hunt far for reasons why it can be the best move strategically.
One common comparison is between the castling and the rook move to the d file or f file. Basically the king may need to move offensively, or defensively:

to cover a flight square for bK,
to attack a pieces (castling can be double attack),
to avoid being checked/mated,
to get out of the way so that the rook delivers check or can move.

In basic retrograde analysis, castling is used as OP pointed out, to deny the opponent's castling in certain situations.
In more sophisticated retrograde analysis, under the A Posteriori condition one player captures e.p., which would not normally be allowed, but a later castling &quot;proves&quot; that the e.p. was in fact justified as no other move could have been made.
In Dead Reckoning, castling may be the only way to keep the game alive, even if the result of the problem is in the end a draw. This also may allow the legality of castling to be deduced through retrograde analysis, without using the conventions. It is not normally possible to reason positively about castling using R.A.
In an antique version of the conventions, it was thought that castling would reset the counter for draw by 50 moves. So a few problems by Plaksin exploit this trick. This is still a matter of controversy even today.
There are also joke problems involving &quot;playing at odds&quot; so one player is missing a rook, but is still allowed to castle with the king moving twice, even though no rook actually moves. I don't know whether occupation of the vacant corner square would be enough to demolish the castling right, generally not, as some of these problems have a rook on the haunted corner square which did not originate there, either coming from the other side or promoting.
I'm aware this is a all bit dry so far, but we could find examples of all of these ideas if folk are interested.