To see all files in a package:
brew ls
To find the package for a file, look at the file like this:
ls -l /usr/local/bin/whatever
If it was installed by Homebrew, it will be a symlink into /usr/local/Cellar/something
, so that will tell you what package it's from.