Security and resource optimization are two of the most critical concerns in cloud computing. A cloud provider must ensure customers with appropriate security, while optimizing the use of cloud resources. In this paper, we present a framework which optimizes both the use of cloud resources and security provided to the customers in an infrastructure as a service (IaaS) cloud. Our framework offers secure usage control of sensitive data within secure virtual machines (VMs), which are dynamically instantiated while optimizing both security and resources allocated to the VMs. These resources are then allocated to the VMs using an optimization model based upon randomized algorithms. We demonstrate that both security and resources can be efficiently optimized within a cloud setting using our formal mathematical model and usage management framework.