This will not repair a JPEG
It is worth being direct about the most common reason people look for this conversion. Converting a JPG to PNG does not recover detail the JPEG compressor threw away. Those losses are already baked into the pixels; PNG simply stores them perfectly, artefacts and all. The usual result is a file several times larger that looks identical.
There is no format that undoes JPEG compression, because the discarded information is not stored anywhere. If you need a clean version, you need the original.
When it is genuinely worth doing
Three cases justify it. First, when you are about to edit: PNG is lossless, so repeated saves during editing do not accumulate generation loss the way re-saving a JPEG does. Second, when you need transparency — you cannot add an alpha channel to a JPEG, so converting first is a prerequisite for cutting out a background. Third, when a tool or platform simply requires PNG.
If the goal is a smaller file rather than a different format, compress the image instead. To go the other way once editing is finished, PNG to JPG will get the size back down.