The aim of this paper is to extend to ternary algebras the classical theory of formal deformations of algebras introduced by Gerstenhaber. The associativity of ternary algebras is available in two forms, totally associative case or partially associative case. To any partially associative algebra corresponds by anti-commutation a ternary Lie algebra. In this work, we summarize the principal definitions and properties as well as classification in dimension 2 of these algebras. Then we focus ourselves on the partially associative ternary algebras, we construct the first groups of a cohomolgy adapted to formal deformations and then we work out a theory of formal deformation in a way similar to the binary algebras.