Yes, f(x)‘s “When I’m Alone” is indeed the same song that Carly Rae Jepsen wrote about masturbation.
https://www.youtube.com/watch?v=QiaxkNnT2Vc
Appropriately enough, “When I’m Alone” has quite a build and an explosion at the hook, and as a bonus it works better sonically than their title track.
…
However, unless I’m missing nuances, while the song was still composed by Carly Rae Jepsen, the lyrics are not explictly some kind of masturbation tribute like I had hoped it would be for the newer, “maturer” f(x). Alas.