For massive multiple-input multiple-output (MIMO) systems, pilot contamination reduces the data transmission capacity owing to the inter-cell interference of non-orthogonal pilots reusage. To develop efficient mobile communication, it is necessary to mitigate pilot contamination. To address this problem, we propose an annealing-based pilot allocation method using Digital Annealer to provide solution for Ising machine. The proposed method is a max k-cut-based approach, where the graph represents the potential strength of pilot contamination among users in other cells. By using this proposed method, users who have strong relationship with pilot contamination will be assigned different pilots. Experiment results show that the proposed method can realize optimal pilot allocation and mitigate pilot contamination. Compared with conventional methods, the proposal achieves the best performance which can increase the minimum achievable rate and show higher SINR, especially when the numbers of users and cells are large.