But you don't.
A lot of people make a lot of fuss about it, but, basically, a JPEG file is an image type.
It has a fancy name but it is just the format in which your image is stored.
We could also store images as TIFFs or RAWs.
But the commonest is JPEGs.
When you take a picture your camera will write the image onto the memory card - this is likely to be a JPEG file.
Your camera and computer will do it all for you.
The image you take is usually very large so the camera or computer compresses it into a JPEG file.
And because JPEGs are smaller than normal files, this means you can store more images in the space available.
There is, inevitably, some loss of quality in the image as it is compressed into a JPEG, but you are unlikely to notice it unless you are being very observant or printing large prints.
In fact your camera might have different "qualities" of JPEG - large, medium, small.
The larger the file the better the quality but the greater amount of space it takes up on you camera's memory card or computer.
Conversely, the smaller the file the less the quality and the less space it requires.
You should experiment with different JPEG settings - in most cases and at normal sizes you won't see any difference.