Continuum electrostatic models have had quantitative success in describing electrostatic-mediated phenomena on atomistic scales; however, there continues to be significant disagreement about how to assign dielectric constants in mixed, nonhomogeneous systems. We introduce a method for determining a position-dependent dielectric profile from molecular dynamics simulations. In this method, the free energy of introducing a test charge is computed two ways: from a free energy perturbation calculation and from a numerical solution to Poisson's Equation. The dielectric profile of the system is then determined by minimizing the discrepancy between these two calculations simultaneously for multiple positions of the test charge. We apply this method to determine the dielectric profile of a lipid bilayer surrounded by water. We find good agreement with dielectric models for lipid bilayers obtained by other approaches. The free energy of transferring an ion from bulk water to the lipid bilayer computed from the atomistic simulations indicates that large errors are introduced when the bilayer is represented as a single slab of low dielectric embedded in the higher-dielectric solvent. Significant improvement results from introducing an additional layer of intermediate dielectric ( approximately 3) on each side of the low dielectric core extending from approximately 12 A to 18 A. A small dip in transfer free energy just outside the lipid headgroups indicates the presence of a very high dielectric. These results have implications for the design of implicit membrane models and our understanding of protein-membrane interactions.