You can use
dpkg command to find out which installed package owns a file:
-S, --search filename-search-pattern... Search for a filename from installed packages.
$ dpkg -S /bin/ls coreutils: /bin/ls
You can either search with a full path or with just the filename.
If you wish to search for files not yet installed on your computer, you can use the Ubuntu Packages Search, or
apt-file as described in a different answer.
apt-file command can do this for you from the command line. I use it frequently when building packages from source. For files provided by packages that are already installed on your system,
apt-cache is another choice.
sudo apt-get install apt-file
Then, you need to update it’s database:
sudo apt-file update
And, finally, search the file:
$ apt-file find kwallet.h kdelibs5-dev: /usr/include/kwallet.h libkf5wallet-dev: /usr/include/KF5/KWallet/kwallet.h
However a much friendlier way is to use the Ubuntu Packages Search website. They have an option to “search the contents of packages” for a specific filename.
There’s also apt-file for looking up files in packages that aren’t installed. For example:
apt-file list packagename