These two file formats use different algorithms for compression making them more suitable for certain tasks.
JPG is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. Due to the loss of information, blurs and artefacts tend to appear. These become a lot more apparent when there are sharp outlines and clear edges.  JPG does not support alpha – the images can’t have transparent areas.
PNG is a lossless image compression format. Its compression is based on combining chunks of similar colours. The format is palette based and you can reduce the palette for even smaller files – or when creating pixel art where the palette is essential to the design. PNG also allows for transparency – images can have “see-through” areas (e.g. show a character without a background).
For the best possible quality PNG is the better choice for vector based designs to keep the crisp look and maintain transparency.