Plug-in electric vehicles (PEVs) are key new energy technology to reduce the fossil fuel usage and therefore environmental pollution. The vehicle-to-grid (V2G) technology in the smart grid infrastructure can exploit the electrical energy storage ability of PEV batteries to enhance the stability and reduce peak power demand of the power grid. Through V2G, PEV owners can reduce cost through properly scheduling PEV charging (and perhaps discharging at some time) and at the same time mitigate the negative impacts on the grid. However, there are challenges with V2G services because it is not clear how much PEV battery aging, and therefore also the associated warranty, are affected during V2G operation. This paper addresses the problem of PEV charging under dynamic pricing, taking into account the degradation of battery state-of-health (SoH) during V2G operations. The objective function to minimize therefore becomes the summation of the energy during PEV charging (and perhaps discharging at some moment) and the extra cost associated with the aging of PEV battery. An optimal algorithm of PEV battery charging is derived to minimize the objective function based on convex optimization techniques. Moreover, this algorithm also accurately accounts for the power loss during charging/discharging of PEV batteries and in power conversion circuitries, which is often neglected in the reference work. Experimental results demonstrate that the proposed charging control algorithm is able to minimize the combination of electricity cost and battery aging cost, whereas a naive algorithm which only consider the electricity cost may result in as high as 9X battery aging rate.