There is no simple answer to this. It depends on several factors, and what you need at one time may not be suitable in other circumstances. But here are a few pointers to help you decide.
If you want the maximum image quality, shoot at maximum resolution with low JPEG/HEIF compression (best quality, large files), or preferably in RAW format. However, this not only takes up more memory card space, but also reduces the number of shots you can take in a burst before your camera's buffer fills up, and it increases the time it takes to transfer the images later. This won't always matter, but is important if you want to shoot rapid sequences at sports events or share images with others quickly.
Also, if you plan to do a lot of post-capture processing or need to produce very large (poster-size or even larger) prints, then it’s usually best to capture the highest quality RAW files with the least compression, to give you the most image data to work with.
On the other hand, if you want rapid access to your images, shooting compressed JPEG files allows you to read the files directly from the memory card. Don't assume that JPEG means poor image quality. Unless you select the lowest quality, you are in effect just letting the camera do the processing for you, carrying out a preset RAW conversion using optimised standard settings. The results will be fine for on-screen viewing or prints up to A4 size or so.
If you want JPEGs to share quickly but also the option to edit your shots later with maximum flexibility, and speed and memory card space are not an issue, don't overlook the option of RAW+JPEG, which saves each image in both formats simultaneously.
If your camera offers the option of HEIF, give it a try. It promises the best of both worlds, and is now being supported in most editing software.
The best way to find what works for you is to shoot the same subject in different file formats, at different combinations of resolution and compression, and take a look at the images on a computer screen. You should also print images from the smallest and largest files and see what differences, if any, you can discern. You might be surprised to discover that reducing resolution can have less perceptible effect than you imagine.