In this work, we consider an energy harvesting device (EHD) served by an access point with a single antenna that is used for both wireless power transfer (WPT) and data transfer. The objective is to maximize the expected throughput of the EHD over a finite horizon when the channel state information is only available causally. The EHD is energized by WPT for a certain duration, which is subject to optimization, and then, EHD transmits its information bits to the AP until the end of the time horizon by employing optimal dynamic power allocation. The joint optimization problem is modeled as a dynamic programming problem. Based on the characteristic of the problem, we prove that a time dependent threshold type structure exists for the optimal WPT duration, and we obtain closed form solution to the dynamic power allocation in the uplink period.