A control device for an internal combustion engine, the internal combustion engine including an actuator, wherein the control device is configured to operate the actuator by giving a command value to the actuator, the control device comprising: an electronic control unit configured to calculate the command value at a predetermined control cycle in accordance with a first control algorithm, wherein the electronic control unit is configured to calculate the command value at the predetermined control cycle in accordance with a second control algorithm, the second control algorithm differing from the first control algorithm, the second control algorithm including a feedback control including an I control and being in accordance with a deviation, the deviation being between a target value and a current value, and the second control algorithm including a feedforward control, wherein the electronic control unit is configured to switch between the first control algorithm and the second control algorithm for the calculation of the command value, and wherein the electronic control unit is configured, when the present control cycle is the first control cycle after switching from the first control algorithm to the second control algorithm, to calculate the value of the command value by adding i the value of the term of the second control algorithm changing in accordance with the deviation calculated in the present control cycle to ii the command value calculated in the previous control cycle in accordance with the first control algorithm, and to calculate the value of the I term of the I control of the previous control cycle by subtracting i the current value of a feedforward term of the feedforward control from ii the command value calculated in the previous control cycle in accordance with the first control algorithm, wherein the value of the term of the second control algorithm changing in accordance with the deviation calculated in the present control cycle includes an update amount of an I term of the I control calculated in the present control cycle. an electronic control unit configured to calculate the command value at a predetermined control cycle in accordance with a first control algorithm, wherein the electronic control unit is configured to calculate the command value at the predetermined control cycle in accordance with a second control algorithm, the second control algorithm differing from the first control algorithm, the second control algorithm including a feedback control including an I control and being in accordance with a deviation, the deviation being between a target value and a current value, and the second control algorithm including a feedforward control, wherein the electronic control unit is configured to switch between the first control algorithm and the second control algorithm for the calculation of the command value, and wherein the electronic control unit is configured, when the present control cycle is the first control cycle after switching from the first control algorithm to the second control algorithm, to calculate the value of the command value by adding i the value of the term of the second control algorithm changing in accordance with the deviation calculated in the present control cycle to ii the command value calculated in the previous control cycle in accordance with the first control algorithm, and to calculate the value of the I term of the I control of the previous control cycle by subtracting i the current value of a feedforward term of the feedforward control from ii the command value calculated in the previous control cycle in accordance with the first control algorithm, wherein the value of the term of the second control algorithm changing in accordance with the deviation calculated in the present control cycle includes an update amount of an I term of the I control calculated in the present control cycle.