API
Use the \Magento\Framework\View\Element\AbstractBlock::getViewFileUrl() method:
Usage examples
The file will be deployed as a symbolic link into the pub folder:

https://github.com/magento/magento2/blob/2ea8cdd7/lib/web/images/loader-1.gif
The file will be deployed as a symbolic link into the pub folder:

A custom file inside a design theme

The file will be deployed as a symbolic link into the pub folder:

So you get it URL wuth the code:
$block->getViewFileUrl('images/test.jpg');